when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. List<String>? tags,
    2. String? summary,
    3. String? description,
    4. ExternalDocs? externalDocs,
    5. String? id,
    6. List<Parameter>? parameters,
    7. RequestBody? requestBody,
    8. Map<String, Response>? responses,
    9. Map<String, ApiCallback>? callbacks,
    10. bool? deprecated,
    11. List<Security>? security,
    12. List<Server>? servers,
    )
)

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?>(TResult Function( List<String>? tags,  String? summary,  String? description,  ExternalDocs? externalDocs, @JsonKey(name: 'operationId')  String? id,  List<Parameter>? parameters,  RequestBody? requestBody,  Map<String, Response>? responses, @_ApiCallbackMapConverter()  Map<String, ApiCallback>? callbacks,  bool? deprecated,  List<Security>? security,  List<Server>? servers)  $default,) {final _that = this;
switch (_that) {
case _Operation():
return $default(_that.tags,_that.summary,_that.description,_that.externalDocs,_that.id,_that.parameters,_that.requestBody,_that.responses,_that.callbacks,_that.deprecated,_that.security,_that.servers);case _:
  throw StateError('Unexpected subclass');

}
}