map<TResult extends Object?> method

  1. @optionalTypeArgs
TResult map<TResult extends Object?>({
  1. required TResult cookie(
    1. ParameterCookie value
    ),
  2. required TResult header(
    1. ParameterHeader value
    ),
  3. required TResult query(
    1. ParameterQuery value
    ),
  4. required TResult path(
    1. 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');

}
}