mapOrNull<TResult extends Object?> method
TResult?
mapOrNull<TResult extends Object?>({
- TResult? general(
- ApiResponseExceptionGeneral value
- TResult? sapMessage(
- SapHeadersException value
- TResult? csrfToken(
- CsrfTokenException value
- TResult? transport(
- TransportException value
- TResult? noResource(
- NoResourceException value
- TResult? unauthorized(
- UnauthorizedException value
- TResult? timeout(
- TimeoutException value
- TResult? materialDocument(
- MaterialDocumentException value
- TResult? batchClassification(
- BatchClassificationException value
A variant of map that fallback to returning null.
It is equivalent to doing:
switch (sealedClass) {
case final Subclass value:
return ...;
case _:
return null;
}
Implementation
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( ApiResponseExceptionGeneral value)? general,TResult? Function( SapHeadersException value)? sapMessage,TResult? Function( CsrfTokenException value)? csrfToken,TResult? Function( TransportException value)? transport,TResult? Function( NoResourceException value)? noResource,TResult? Function( UnauthorizedException value)? unauthorized,TResult? Function( TimeoutException value)? timeout,TResult? Function( MaterialDocumentException value)? materialDocument,TResult? Function( BatchClassificationException value)? batchClassification,}){
final _that = this;
switch (_that) {
case ApiResponseExceptionGeneral() when general != null:
return general(_that);case SapHeadersException() when sapMessage != null:
return sapMessage(_that);case CsrfTokenException() when csrfToken != null:
return csrfToken(_that);case TransportException() when transport != null:
return transport(_that);case NoResourceException() when noResource != null:
return noResource(_that);case UnauthorizedException() when unauthorized != null:
return unauthorized(_that);case TimeoutException() when timeout != null:
return timeout(_that);case MaterialDocumentException() when materialDocument != null:
return materialDocument(_that);case BatchClassificationException() when batchClassification != null:
return batchClassification(_that);case _:
return null;
}
}