Class Fallible<SuccessType,FailureType>
java.lang.Object
gov.nasa.jpl.aerie.merlin.server.http.Fallible<SuccessType,FailureType>
- Type Parameters:
SuccessType- The value type stored on successFailureType- The error type stored on failure
A class representing a fallible operation result.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <SuccessType,FailureType>
Fallible<SuccessType, FailureType> failure(FailureType error) Return a Fallible representing a failure with a value.static <SuccessType,FailureType>
Fallible<SuccessType, FailureType> Return a Fallible representing a failure with a value and a message.get()Get the valueGet the failure value.Get the failure wrapped in anOptional.Get the failure message.Get the value wrapped in anOptional.booleanCheck if the operation was a failure.static <SuccessType,FailureType>
Fallible<SuccessType, FailureType> of(SuccessType value) Return a Fallible with a successful value.
-
Method Details
-
isFailure
public boolean isFailure()Check if the operation was a failure.- Returns:
- true if the operation was a failure, otherwise false.
-
get
Get the value- Returns:
- The value;
-
getOptional
Get the value wrapped in anOptional. -
getMessage
Get the failure message. -
getFailure
Get the failure value. -
getFailureOptional
Get the failure wrapped in anOptional. -
of
Return a Fallible with a successful value.- Type Parameters:
SuccessType- The type of the value.- Parameters:
value- The successful value.- Returns:
- A successful Fallible.
-
failure
public static <SuccessType,FailureType> Fallible<SuccessType,FailureType> failure(FailureType error) Return a Fallible representing a failure with a value.- Type Parameters:
FailureType- The type of the value.- Parameters:
error- The value indicating failure.- Returns:
- A failed Fallible with a value.
-
failure
public static <SuccessType,FailureType> Fallible<SuccessType,FailureType> failure(FailureType error, String message) Return a Fallible representing a failure with a value and a message.- Type Parameters:
FailureType- > The type of the value.- Parameters:
error- The value indicating failure.message- The message associated with the failure.- Returns:
- A failed Fallible with a value and a message.
-