map<TResult extends Object?> method
- @optionalTypeArgs
- required TResult cookie(
- ParameterCookie value
- required TResult header(
- ParameterHeader value
- required TResult query(
- ParameterQuery value
- required TResult path(
- ParameterPath value
A switch-like method, using callbacks.
Callbacks receives the raw object, upcasted. It is equivalent to doing:
switch (sealedClass) {
case final Subclass value:
return ...;
case final Subclass2 value:
return ...;
}
Implementation
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( ParameterCookie value) cookie,required TResult Function( ParameterHeader value) header,required TResult Function( ParameterQuery value) query,required TResult Function( ParameterPath value) path,}){
final _that = this;
switch (_that) {
case ParameterCookie():
return cookie(_that);case ParameterHeader():
return header(_that);case ParameterQuery():
return query(_that);case ParameterPath():
return path(_that);case _:
throw StateError('Unexpected subclass');
}
}