Interface Result<T,E> 
- Type Parameters:
 T- Value typeE- Error type
public sealed interface Result<T,E> 
Monad that can either be an error or a success and holds either a
 value or an error.
- 
Method Summary
Modifier and TypeMethodDescriptionstatic <T1,T2, E> Result <T2, E> Casting function to translate an erroneous result from one value type to anotherstatic <T,E> Result <T, E> err(E err) Creates an erroneous result out of the specifiederrerror.error()Gets the result's error.If this is a successful result, returns the mapper function's result.Gets the result's value or throws aResultException.getOrThrow(Function<E, X> factory) Gets the result's value or throws an exception specified by thefactoryfunction.If this is an erroneous result, the specifiedconsumerfunction is applied to the result's error value.If this a successful result, the specifiedconsumerfunction is applied to the result's value.static <T> Result<T, DelphiException> ioError(IOException exc) Wraps an IO error in a result.booleanisError()Tests if this result is erroneous.booleanTests if this result is successful.If a value is present, returns a new result with the return value of the specifiedmapperfunction, otherwise, if this is an erroneous result, then nothing happens and this result is cast to the mapped type.If this is an erroneous result, returns the mapper functions result as a new error result.nothing()Get the successful 'nothing' result.static <T,E> Result <T, E> ok(T value) Creates a successful result with the specified non-nullvalue.If the result is an erroneous result, thedefaultValueis returned, otherwise the result's value is returned.If the result is an erroneous result, thegetterfunction is called to get the return value.value()Gets the value of the result. 
- 
Method Details
- 
err
Creates an erroneous result out of the specifiederrerror.- Parameters:
 err- Error value- Returns:
 - Created result
 - Throws:
 NullPointerException- Iferrisnull
 - 
err
Casting function to translate an erroneous result from one value type to another- Parameters:
 res- Result to cast- Returns:
 - Casted result
 - Throws:
 IllegalArgumentException- If the specified result is non-erroneous
 - 
ok
Creates a successful result with the specified non-nullvalue.- Parameters:
 value- Value- Returns:
 - Created result
 - Throws:
 NullPointerException- Ifvalueisnull
 - 
ioError
Wraps an IO error in a result.
Returned results Exception Types Returned error code NoSuchFileExceptionDelphiException.ERR_NO_FILEAccessDeniedExceptionDelphiException.ERR_ACCESS_DENIEDAny other IO exception type DelphiException.ERR_IO_ERROR- Parameters:
 exc- Exception to wrap- Returns:
 - Error result
 
 - 
nothing
 - 
value
 - 
error
 - 
map
If a value is present, returns a new result with the return value of the specifiedmapperfunction, otherwise, if this is an erroneous result, then nothing happens and this result is cast to the mapped type.If the mapper function returns
null, aNullPointerExceptionis thrown.- Parameters:
 mapper- Mapping function- Returns:
 - Mapped result.
 - Throws:
 NullPointerException- Ifmapperisnull, or if the result of the mapper function isnull.
 - 
flatMap
If this is a successful result, returns the mapper function's result. Otherwise, nothing happens and this result is cast to the mapped type and returned.If the mapper function return
null, aNullPointerExceptionis thrown.- Parameters:
 mapper- Mapping function- Returns:
 - Mapped result
 - Throws:
 NullPointerException- Ifmapperisnull, or if the result of the mapper function isnull.
 - 
mapError
If this is an erroneous result, returns the mapper functions result as a new error result. Otherwise, nothing happens and this result is returned.If the mapper function returns
null, aNullPointerExceptionis thrown.- Parameters:
 mapper- Error mapping function- Returns:
 - Error-mapped result
 - Throws:
 NullPointerException- Ifmapperisnull, or if the result of the mapper function isnull.
 - 
isError
boolean isError()Tests if this result is erroneous.- Returns:
 true, if this result has a presenterror(),falseotherwise.
 - 
isSuccess
boolean isSuccess()Tests if this result is successful.- Returns:
 true, if this result has a presentvalue().falseotherwise
 - 
ifError
 - 
ifSuccess
 - 
getOrThrow
Gets the result's value or throws aResultException.If the result's error is a
Throwablethen the thrownResultExceptionwill have the throwable as its cause (Accessible withThrowable.getCause()).
If the result's error is a string, then it will be used as theResultException's message.
Otherwise, a result exception will be thrown with aResultException.getErrorObject()of this result's error value.- Returns:
 - The result's value
 - Throws:
 ResultException- If the result is an erroneous result.
 - 
getOrThrow
 - 
orElse
 - 
orElseGet
 
 -