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 of ServiceResult represents a successful operation. It contains the return value of type SuccessType
    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 provided Consumer if this ServiceResult 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 either SuccessType or FailureType depending on success or failure of the operation.
      static <T> Success<T> of​(T result)
      Creates a Success 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.Result

        isFailure
    • 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 a Success 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 either SuccessType or FailureType depending on success or failure of the operation.
        Specified by:
        map in interface Result<SuccessType,​java.lang.String>
        Specified by:
        map in interface ServiceResult<SuccessType>
        Type Parameters:
        T - the resultant type
        Parameters:
        successFunction - the mapping function to map the SuccessType to the resultant type
        errorFunction - the mapping function to map the FailureType to the resultant error type
        Returns:
        result of type T
      • getErrorMessage

        public java.lang.String getErrorMessage()
        Description copied from interface: Result
        The return message of a failed operation. The return type is of type FailureType
        Specified by:
        getErrorMessage in interface Result<SuccessType,​java.lang.String>
        Specified by:
        getErrorMessage in interface ServiceResult<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 interface Result<SuccessType,​java.lang.String>
        Returns:
        true indicating the success of the operation