Gemfire JavaDocs_test
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 theFailure
type but required by theServiceResult
- All Implemented Interfaces:
Result<SuccessType,java.lang.String>
,ServiceResult<SuccessType>
public class Failure<SuccessType> extends java.lang.Object implements ServiceResult<SuccessType>
This type ofServiceResult
represents a failed operation. It contains the errorMessage for the failure.- Since:
- 1.14.0
- See Also:
ServiceResult
,Success
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getErrorMessage()
The return message of a failed operation.SuccessType
getMessage()
The return message of a successful operation.ServiceResult<SuccessType>
ifFailure(java.util.function.Consumer<? super java.lang.String> consumer)
If the result of the operation has failed, invoke the specified consumer with the value, otherwise do nothing.boolean
isFailure()
Returns a boolean to indicate the success or failure of the operation<T> T
map(java.util.function.Function<SuccessType,T> successFunction, java.util.function.Function<java.lang.String,T> errorFunction)
A mapping function that maps to eitherSuccessType
orFailureType
depending on success or failure of the operation.static <T> Failure<T>
of(java.lang.String errorMessage)
Creates aFailure
object containing the errorMessagestatic <T> Failure<T>
of(java.lang.String errorMessage, java.lang.Throwable throwable)
Creates aFailure
object containing the errorMessagestatic <T> Failure<T>
of(java.lang.Throwable throwable)
Creates aFailure
object containing the throwable-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.geode.services.result.Result
isSuccessful
-
Methods inherited from interface org.apache.geode.services.result.ServiceResult
ifSuccessful
-
-
-
-
Method Detail
-
of
public static <T> Failure<T> of(java.lang.String errorMessage)
Creates aFailure
object containing the errorMessage- Type Parameters:
T
- the type of the result- Parameters:
errorMessage
- the error message describing the reason for failure.- Returns:
- an
Failure
instance containing the errorMessage
-
of
public static <T> Failure<T> of(java.lang.Throwable throwable)
Creates aFailure
object containing the throwable- Type Parameters:
T
- the type of the result- Parameters:
throwable
- the error message describing the reason for failure.- Returns:
- an
Failure
instance containing the throwable
-
of
public static <T> Failure<T> of(java.lang.String errorMessage, java.lang.Throwable throwable)
Creates aFailure
object 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
Failure
instance containing the errorMessage
-
map
public <T> T map(java.util.function.Function<SuccessType,T> successFunction, java.util.function.Function<java.lang.String,T> errorFunction)
Description copied from interface:Result
A mapping function that maps to eitherSuccessType
orFailureType
depending on success or failure of the operation.- Specified by:
map
in interfaceResult<SuccessType,java.lang.String>
- Specified by:
map
in 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
public SuccessType getMessage()
Description copied from interface:Result
The return message of a successful operation. The return type is of typeSuccessType
- Specified by:
getMessage
in interfaceResult<SuccessType,java.lang.String>
- Specified by:
getMessage
in interfaceServiceResult<SuccessType>
- Returns:
- the result of the operation
-
getErrorMessage
public java.lang.String getErrorMessage()
Description copied from interface:Result
The return message of a failed operation. The return type is of typeFailureType
- Specified by:
getErrorMessage
in interfaceResult<SuccessType,java.lang.String>
- Specified by:
getErrorMessage
in interfaceServiceResult<SuccessType>
- Returns:
- the failure message of why the operation did not succeed.
-
ifFailure
public ServiceResult<SuccessType> ifFailure(java.util.function.Consumer<? super java.lang.String> consumer)
Description copied from interface:ServiceResult
If the result of the operation has failed, invoke the specified consumer with the value, otherwise do nothing.- Specified by:
ifFailure
in interfaceServiceResult<SuccessType>
- Parameters:
consumer
- block to be executed if a value is present- Returns:
- this
ServiceResult
-
isFailure
public boolean isFailure()
Description copied from interface:Result
Returns a boolean to indicate the success or failure of the operation- Specified by:
isFailure
in interfaceResult<SuccessType,java.lang.String>
- Returns:
- true indicating the failure of the operation
-
-