T
- The type of the successful result objectpublic class Result<T> extends Object
Modifier and Type | Method and Description |
---|---|
static <T> Result<T> |
failure(Throwable failure)
Creates a failure result object.
|
Throwable |
getFailure()
The failure exception.
|
T |
getValue()
The result value.
|
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 successful result object.
|
public static <T> Result<T> success(T value)
T
- The type of the result objectvalue
- The object representing the result of the operationpublic static <T> Result<T> failure(Throwable failure)
T
- The type of the result objectfailure
- An exception representing the failurepublic Throwable getFailure()
public T getValue()
public boolean isSuccess()
public boolean isFailure()