when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>({
  1. required TResult object(
    1. String? title,
    2. String? description,
    3. dynamic defaultValue,
    4. String? ref,
    5. List<Schema>? allOf,
    6. List<Schema>? oneOf,
    7. List<Schema>? anyOf,
    8. List<String>? required,
    9. Discriminator? discriminator,
    10. ExternalDocs? externalDocs,
    11. Map<String, Schema>? properties,
    12. bool? nullable,
    13. Xml? xml,
    ),
  2. required TResult boolean(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. bool? defaultValue,
    5. bool? nullable,
    6. bool? example,
    7. String? ref,
    ),
  3. required TResult string(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. String? defaultValue,
    5. bool? nullable,
    6. StringFormat? format,
    7. String? pattern,
    8. String? example,
    9. int? minLength,
    10. int? maxLength,
    11. int? exclusiveMinimum,
    12. int? exclusiveMaximum,
    13. String? ref,
    ),
  4. required TResult integer(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. int? defaultValue,
    5. bool? nullable,
    6. IntegerFormat? format,
    7. int? example,
    8. int? minimum,
    9. int? maximum,
    10. int? exclusiveMinimum,
    11. int? exclusiveMaximum,
    12. int? multipleOf,
    13. String? ref,
    ),
  5. required TResult number(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. double? defaultValue,
    5. bool? nullable,
    6. NumberFormat? format,
    7. double? example,
    8. double? minimum,
    9. double? maximum,
    10. int? exclusiveMinimum,
    11. int? exclusiveMaximum,
    12. double? multipleOf,
    13. String? ref,
    ),
  6. required TResult enumeration(
    1. String? title,
    2. String? description,
    3. String? example,
    4. String? defaultValue,
    5. bool? nullable,
    6. String? unknownValue,
    7. List<String>? values,
    8. String? ref,
    ),
  7. required TResult array(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. List? defaultValue,
    5. bool? nullable,
    6. dynamic example,
    7. int? minItems,
    8. int? maxItems,
    9. Schema items,
    10. String? ref,
    ),
  8. required TResult map(
    1. Xml? xml,
    2. String? title,
    3. String? description,
    4. Map? defaultValue,
    5. bool? nullable,
    6. Map? example,
    7. Schema? valueSchema,
    8. String? ref,
    ),
})

A switch-like method, using callbacks.

As opposed to map, this offers destructuring. It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case Subclass2(:final field2):
    return ...;
}

Implementation

@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function( String? title,  String? description, @JsonKey(name: 'default')  dynamic defaultValue, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref, @_SchemaListConverter()  List<Schema>? allOf, @_SchemaListConverter()  List<Schema>? oneOf, @_SchemaListConverter()  List<Schema>? anyOf,  List<String>? required,  Discriminator? discriminator,  ExternalDocs? externalDocs,  Map<String, Schema>? properties,  bool? nullable,  Xml? xml)  object,required TResult Function( Xml? xml,  String? title,  String? description, @JsonKey(name: 'default')  bool? defaultValue,  bool? nullable,  bool? example, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref)  boolean,required TResult Function( Xml? xml,  String? title,  String? description, @JsonKey(name: 'default')  String? defaultValue,  bool? nullable, @JsonKey(unknownEnumValue: JsonKey.nullForUndefinedEnumValue)  StringFormat? format,  String? pattern,  String? example, @JsonKey(fromJson: _fromJsonInt)  int? minLength, @JsonKey(fromJson: _fromJsonInt)  int? maxLength, @JsonKey(fromJson: _fromJsonInt)  int? exclusiveMinimum, @JsonKey(fromJson: _fromJsonInt)  int? exclusiveMaximum, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref)  string,required TResult Function( Xml? xml,  String? title,  String? description, @JsonKey(name: 'default', fromJson: _fromJsonInt)  int? defaultValue,  bool? nullable, @JsonKey(unknownEnumValue: JsonKey.nullForUndefinedEnumValue)  IntegerFormat? format, @JsonKey(fromJson: _fromJsonInt)  int? example, @JsonKey(fromJson: _fromJsonInt)  int? minimum, @JsonKey(fromJson: _fromJsonInt)  int? maximum, @JsonKey(fromJson: _fromJsonInt)  int? exclusiveMinimum, @JsonKey(fromJson: _fromJsonInt)  int? exclusiveMaximum, @JsonKey(fromJson: _fromJsonInt)  int? multipleOf, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref)  integer,required TResult Function( Xml? xml,  String? title,  String? description, @JsonKey(name: 'default', fromJson: _fromJsonDouble)  double? defaultValue,  bool? nullable, @JsonKey(unknownEnumValue: JsonKey.nullForUndefinedEnumValue)  NumberFormat? format, @JsonKey(fromJson: _fromJsonDouble)  double? example, @JsonKey(fromJson: _fromJsonDouble)  double? minimum, @JsonKey(fromJson: _fromJsonDouble)  double? maximum, @JsonKey(fromJson: _fromJsonInt)  int? exclusiveMinimum, @JsonKey(fromJson: _fromJsonInt)  int? exclusiveMaximum, @JsonKey(fromJson: _fromJsonDouble)  double? multipleOf, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref)  number,required TResult Function( String? title,  String? description,  String? example, @JsonKey(name: 'default')  String? defaultValue,  bool? nullable, @JsonKey(includeToJson: false, includeFromJson: false)  String? unknownValue, @JsonKey(name: 'enum')  List<String>? values, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref)  enumeration,required TResult Function( Xml? xml,  String? title,  String? description, @JsonKey(name: 'default')  List? defaultValue,  bool? nullable,  dynamic example, @JsonKey(fromJson: _fromJsonInt)  int? minItems, @JsonKey(fromJson: _fromJsonInt)  int? maxItems,  Schema items, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref)  array,required TResult Function( Xml? xml,  String? title,  String? description, @JsonKey(name: 'default')  Map? defaultValue,  bool? nullable,  Map? example, @JsonKey(name: 'additionalProperties', toJson: _toMapProps, fromJson: _fromMapProps)  Schema? valueSchema, @JsonKey(name: '\$ref')@_SchemaRefConverter()  String? ref)  map,}) {final _that = this;
switch (_that) {
case SchemaObject():
return object(_that.title,_that.description,_that.defaultValue,_that.ref,_that.allOf,_that.oneOf,_that.anyOf,_that.required,_that.discriminator,_that.externalDocs,_that.properties,_that.nullable,_that.xml);case SchemaBoolean():
return boolean(_that.xml,_that.title,_that.description,_that.defaultValue,_that.nullable,_that.example,_that.ref);case SchemaString():
return string(_that.xml,_that.title,_that.description,_that.defaultValue,_that.nullable,_that.format,_that.pattern,_that.example,_that.minLength,_that.maxLength,_that.exclusiveMinimum,_that.exclusiveMaximum,_that.ref);case SchemaInteger():
return integer(_that.xml,_that.title,_that.description,_that.defaultValue,_that.nullable,_that.format,_that.example,_that.minimum,_that.maximum,_that.exclusiveMinimum,_that.exclusiveMaximum,_that.multipleOf,_that.ref);case SchemaNumber():
return number(_that.xml,_that.title,_that.description,_that.defaultValue,_that.nullable,_that.format,_that.example,_that.minimum,_that.maximum,_that.exclusiveMinimum,_that.exclusiveMaximum,_that.multipleOf,_that.ref);case SchemaEnum():
return enumeration(_that.title,_that.description,_that.example,_that.defaultValue,_that.nullable,_that.unknownValue,_that.values,_that.ref);case SchemaArray():
return array(_that.xml,_that.title,_that.description,_that.defaultValue,_that.nullable,_that.example,_that.minItems,_that.maxItems,_that.items,_that.ref);case SchemaMap():
return map(_that.xml,_that.title,_that.description,_that.defaultValue,_that.nullable,_that.example,_that.valueSchema,_that.ref);case _:
  throw StateError('Unexpected subclass');

}
}