Class Failure<SuccessType>
java.lang.Object
org.apache.geode.services.result.impl.Failure<SuccessType>
- Type Parameters:
SuccessType- the result type for a successful operation. Not used by theFailuretype but required by theServiceResult
- All Implemented Interfaces:
Result<SuccessType,,String> ServiceResult<SuccessType>
This type of
ServiceResult represents a failed operation. It contains the
errorMessage for the failure.- Since:
- 1.14.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionThe return message of a failed operation.The return message of a successful operation.If the result of the operation has failed, invoke the specified consumer with the value, otherwise do nothing.booleanReturns a boolean to indicate the success or failure of the operation<T> Tmap(Function<SuccessType, T> successFunction, Function<String, T> errorFunction) A mapping function that maps to eitherSuccessTypeorFailureTypedepending on success or failure of the operation.static <T> Failure<T>Creates aFailureobject containing the errorMessagestatic <T> Failure<T>Creates aFailureobject containing the errorMessagestatic <T> Failure<T>Creates aFailureobject containing the throwableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.geode.services.result.Result
isSuccessfulMethods inherited from interface org.apache.geode.services.result.ServiceResult
ifSuccessful
-
Method Details
-
of
Creates aFailureobject containing the errorMessage- Type Parameters:
T- the type of the result- Parameters:
errorMessage- the error message describing the reason for failure.- Returns:
- an
Failureinstance containing the errorMessage
-
of
Creates aFailureobject containing the throwable- Type Parameters:
T- the type of the result- Parameters:
throwable- the error message describing the reason for failure.- Returns:
- an
Failureinstance containing the throwable
-
of
Creates aFailureobject containing the errorMessage- Type Parameters:
T- the type of the result- Parameters:
errorMessage- the error message describing the reason for failure.throwable- the throwable that caused the failure- Returns:
- an
Failureinstance containing the errorMessage
-
map
Description copied from interface:ResultA mapping function that maps to eitherSuccessTypeorFailureTypedepending on success or failure of the operation.- Specified by:
mapin interfaceResult<SuccessType,String> - Specified by:
mapin interfaceServiceResult<SuccessType>- Type Parameters:
T- the resultant type- Parameters:
successFunction- the mapping function to map the SuccessType to the resultant typeerrorFunction- the mapping function to map the FailureType to the resultant error type- Returns:
- result of type
T
-
getMessage
Description copied from interface:ResultThe return message of a successful operation. The return type is of typeSuccessType- Specified by:
getMessagein interfaceResult<SuccessType,String> - Specified by:
getMessagein interfaceServiceResult<SuccessType>- Returns:
- the result of the operation
-
getErrorMessage
Description copied from interface:ResultThe return message of a failed operation. The return type is of typeFailureType- Specified by:
getErrorMessagein interfaceResult<SuccessType,String> - Specified by:
getErrorMessagein interfaceServiceResult<SuccessType>- Returns:
- the failure message of why the operation did not succeed.
-
ifFailure
Description copied from interface:ServiceResultIf the result of the operation has failed, invoke the specified consumer with the value, otherwise do nothing.- Specified by:
ifFailurein interfaceServiceResult<SuccessType>- Parameters:
consumer- block to be executed if a value is present- Returns:
- this
ServiceResult
-
isFailure
public boolean isFailure()Description copied from interface:ResultReturns a boolean to indicate the success or failure of the operation- Specified by:
isFailurein interfaceResult<SuccessType,String> - Returns:
- true indicating the failure of the operation
-