Gemfire JavaDocs
Class Success<SuccessType>
- java.lang.Object
-
- org.apache.geode.services.result.impl.Success<SuccessType>
-
- Type Parameters:
SuccessType
- the result type for a successful operation.
- All Implemented Interfaces:
Result<SuccessType,java.lang.String>
,ServiceResult<SuccessType>
public class Success<SuccessType> extends java.lang.Object implements ServiceResult<SuccessType>
This type ofServiceResult
represents a successful operation. It contains the return value of typeSuccessType
- Since:
- 1.14.0
- See Also:
ServiceResult
,Failure
-
-
Field Summary
Fields Modifier and Type Field Description static Success<java.lang.Boolean>
SUCCESS_TRUE
-
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>
ifSuccessful(java.util.function.Consumer<? super SuccessType> consumer)
Executes the providedConsumer
if thisServiceResult
is a success.boolean
isSuccessful()
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> Success<T>
of(T result)
Creates aSuccess
object containing the errorMessage-
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.ServiceResult
ifFailure
-
-
-
-
Field Detail
-
SUCCESS_TRUE
@Immutable public static final Success<java.lang.Boolean> SUCCESS_TRUE
-
-
Method Detail
-
of
public static <T> Success<T> of(T result)
Creates aSuccess
object containing the errorMessage- Type Parameters:
T
- the type of the result- Parameters:
result
- the return value of the successful operation- Returns:
- a
Success
instance containing the return value
-
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.
-
isSuccessful
public boolean isSuccessful()
Description copied from interface:Result
Returns a boolean to indicate the success or failure of the operation- Specified by:
isSuccessful
in interfaceResult<SuccessType,java.lang.String>
- Returns:
- true indicating the success of the operation
-
ifSuccessful
public ServiceResult<SuccessType> ifSuccessful(java.util.function.Consumer<? super SuccessType> consumer)
Description copied from interface:ServiceResult
Executes the providedConsumer
if thisServiceResult
is a success.- Specified by:
ifSuccessful
in interfaceServiceResult<SuccessType>
- Parameters:
consumer
- theConsumer
to be executed on success.- Returns:
- this
ServiceResult
-
-