T
- The type of the successful result objectpublic interface Result<T>
Modifier and Type | Method and Description |
---|---|
static <T> Result<T> |
failure(Throwable failure)
Creates a new failure result.
|
Throwable |
getThrowable()
The failure exception.
|
T |
getValue()
The result value.
|
default T |
getValueOrThrow()
Returns the value if this is a success result, or throws the exception if it's a failure.
|
boolean |
isFailure()
True if this was a failure result.
|
boolean |
isSuccess()
True if this was a success result.
|
static <T> Result<T> |
success(T value)
Creates a new successful result.
|
static <T> Result<T> success(T value)
T
- the type of the resultvalue
- the result valuestatic <T> Result<T> failure(Throwable failure)
T
- the type of the resultfailure
- the failureThrowable getThrowable()
T getValue()
boolean isSuccess()
boolean isFailure()