Gemfire JavaDocs_test
Package org.apache.geode.services.result
Interface ServiceResult<SuccessType>
-
- Type Parameters:
SuccessType
- the return type for a successful operation.
- All Superinterfaces:
Result<SuccessType,java.lang.String>
public interface ServiceResult<SuccessType> extends Result<SuccessType,java.lang.String>
TheServiceResult
type is an attempt at the function construct of Either. In this implementation aServiceResult
can define either success or failure (error) using the same type.- Since:
- 1.14.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default 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.default 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.default ServiceResult<SuccessType>
ifSuccessful(java.util.function.Consumer<? super SuccessType> consumer)
Executes the providedConsumer
if thisServiceResult
is a success.<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.-
Methods inherited from interface org.apache.geode.services.result.Result
isFailure, isSuccessful
-
-
-
-
Method Detail
-
map
<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>
- 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
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>
- Returns:
- the result of the operation
-
getErrorMessage
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>
- Returns:
- the failure message of why the operation did not succeed.
-
ifSuccessful
default ServiceResult<SuccessType> ifSuccessful(java.util.function.Consumer<? super SuccessType> consumer)
Executes the providedConsumer
if thisServiceResult
is a success.- Parameters:
consumer
- theConsumer
to be executed on success.- Returns:
- this
ServiceResult
-
ifFailure
default 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.- Parameters:
consumer
- block to be executed if a value is present- Returns:
- this
ServiceResult
- Throws:
java.lang.NullPointerException
- if value is present andconsumer
is null
-
-