maybeWhen<TResult extends Object?> method
- @optionalTypeArgs
- TResult cookie()?,
- TResult header()?,
- TResult query()?,
- TResult path()?,
- required TResult orElse(),
A variant of when
that fallback to an orElse
callback.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return orElse();
}
Implementation
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function( String? name, String? description, bool? required, bool? deprecated, String? style, bool? explode, bool? allowReserved, String? example, Schema schema, @JsonKey(name: '\$ref')@_ParamRefConverter() String? ref)? cookie,TResult Function( String? name, String? description, bool? required, bool? deprecated, String? style, bool? explode, bool? allowReserved, String? example, Schema schema, @JsonKey(name: '\$ref')@_ParamRefConverter() String? ref)? header,TResult Function( String? name, String? description, bool? required, bool? deprecated, String? style, bool? explode, bool? allowReserved, String? example, Schema schema, @JsonKey(name: '\$ref')@_ParamRefConverter() String? ref)? query,TResult Function( String? name, String? description, bool? deprecated, String? style, bool? explode, bool? allowReserved, String? example, Schema? schema, @JsonKey(name: '\$ref')@_ParamRefConverter() String? ref)? path,required TResult orElse(),}) {final _that = this;
switch (_that) {
case ParameterCookie() when cookie != null:
return cookie(_that.name,_that.description,_that.required,_that.deprecated,_that.style,_that.explode,_that.allowReserved,_that.example,_that.schema,_that.ref);case ParameterHeader() when header != null:
return header(_that.name,_that.description,_that.required,_that.deprecated,_that.style,_that.explode,_that.allowReserved,_that.example,_that.schema,_that.ref);case ParameterQuery() when query != null:
return query(_that.name,_that.description,_that.required,_that.deprecated,_that.style,_that.explode,_that.allowReserved,_that.example,_that.schema,_that.ref);case ParameterPath() when path != null:
return path(_that.name,_that.description,_that.deprecated,_that.style,_that.explode,_that.allowReserved,_that.example,_that.schema,_that.ref);case _:
return orElse();
}
}