maybeMap<TResult extends Object?> method
- @optionalTypeArgs
- TResult object(
- SchemaObject value
- TResult boolean(
- SchemaBoolean value
- TResult string(
- SchemaString value
- TResult integer(
- SchemaInteger value
- TResult number(
- SchemaNumber value
- TResult enumeration(
- SchemaEnum value
- TResult array(
- SchemaArray value
- TResult map(
- SchemaMap value
- required TResult orElse(),
A variant of map that fallback to returning orElse.
It is equivalent to doing:
switch (sealedClass) {
case final Subclass value:
return ...;
case _:
return orElse();
}
Implementation
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( SchemaObject value)? object,TResult Function( SchemaBoolean value)? boolean,TResult Function( SchemaString value)? string,TResult Function( SchemaInteger value)? integer,TResult Function( SchemaNumber value)? number,TResult Function( SchemaEnum value)? enumeration,TResult Function( SchemaArray value)? array,TResult Function( SchemaMap value)? map,required TResult orElse(),}){
final _that = this;
switch (_that) {
case SchemaObject() when object != null:
return object(_that);case SchemaBoolean() when boolean != null:
return boolean(_that);case SchemaString() when string != null:
return string(_that);case SchemaInteger() when integer != null:
return integer(_that);case SchemaNumber() when number != null:
return number(_that);case SchemaEnum() when enumeration != null:
return enumeration(_that);case SchemaArray() when array != null:
return array(_that);case SchemaMap() when map != null:
return map(_that);case _:
return orElse();
}
}