T
- The type of the successful result object.public 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 object.value
- The object representing the result of the operation.public static <T> Result<T> failure(Throwable failure)
failure
- An exception representing the failurepublic Throwable getFailure()
public T getValue()
public boolean isSuccess()
public boolean isFailure()