S
- The success value if the operation was successful.E
- The error if the operation was not successful.public final class Result<S,E>
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
E |
getError()
The error, if the operation resulted in an error.
|
S |
getSuccessValue()
The result of a successful operation.
|
int |
hashCode() |
boolean |
hasSuccessValue()
Returns true if the operation was successful and the generic parameter
S is not of
type Void , false otherwise. |
boolean |
isError()
true if the operation resulted in an error. |
boolean |
isSuccess()
true if the operation was successful. |
static <S,E> Result<S,E> |
newError(E error)
Creates a new Result object representing an error.
|
static <E> Result<java.lang.Void,E> |
newSuccess()
Creates a new Result object representing a success without a success value.
|
static <S,E> Result<S,E> |
newSuccess(S successValue)
Creates a new Result object representing a success with a success value.
|
java.lang.String |
toString() |
@NonNull public static <S,E> Result<S,E> newError(@NonNull E error)
Creates a new Result object representing an error.
This method is provided for testing purposes.
@NonNull public static <S,E> Result<S,E> newSuccess(@NonNull S successValue)
Creates a new Result object representing a success with a success value.
This method is provided for testing purposes.
@NonNull public static <E> Result<java.lang.Void,E> newSuccess()
Creates a new Result object representing a success without a success value.
This method is provided for testing purposes.
@NonNull public S getSuccessValue() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if the operation resulted in an error or there was no success
value.public boolean hasSuccessValue()
S
is not of
type Void
, false otherwise.@NonNull public E getError() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if isError()
is false.public boolean isError()
true
if the operation resulted in an error. See getError()
} for the cause.public boolean isSuccess()
true
if the operation was successful. See getSuccessValue()
} for the result
when the generic parameter S
is not of type Void
.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object