when<TResult extends Object?> method
- @optionalTypeArgs
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( String? summary, String? description, Operation? get, Operation? put, Operation? post, Operation? delete, Operation? options, Operation? head, Operation? patch, Operation? trace, List<Server>? servers, List<Parameter>? parameters, @JsonKey(name: '\$ref')@_PathRefConverter() String? ref) $default,) {final _that = this;
switch (_that) {
case _PathItem():
return $default(_that.summary,_that.description,_that.get,_that.put,_that.post,_that.delete,_that.options,_that.head,_that.patch,_that.trace,_that.servers,_that.parameters,_that.ref);case _:
throw StateError('Unexpected subclass');
}
}