when<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- Map<
String, Schema> ? schemas, - Map<
String, Response> ? responses, - Map<
String, Parameter> ? parameters, - Map<
String, Example> ? examples, - Map<
String, RequestBody> ? requestBodies, - Map<
String, Header> ? headers, - Map<
String, SecurityScheme> ? securitySchemes, - Map<
String, Link> ? links, - Map<
String, ApiCallback> ? callbacks, - Map<
String, PathItem> ? pathItems,
- Map<
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(@_SchemaMapConverter() Map<String, Schema>? schemas, Map<String, Response>? responses, Map<String, Parameter>? parameters, Map<String, Example>? examples, Map<String, RequestBody>? requestBodies, Map<String, Header>? headers, Map<String, SecurityScheme>? securitySchemes, Map<String, Link>? links, @_ApiCallbackMapConverter() Map<String, ApiCallback>? callbacks, Map<String, PathItem>? pathItems) $default,) {final _that = this;
switch (_that) {
case _Components():
return $default(_that.schemas,_that.responses,_that.parameters,_that.examples,_that.requestBodies,_that.headers,_that.securitySchemes,_that.links,_that.callbacks,_that.pathItems);case _:
throw StateError('Unexpected subclass');
}
}