Success (Apache Geode 2.0.2)
Description: declaration: package: org.apache.geode.services.result.impl, class: Success

Package org.apache.geode.services.result.impl

# 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,String>`, `ServiceResult<SuccessType>`

public class Success<SuccessType> extends 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 final Success<Boolean>`
  `SUCCESS_TRUE`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getErrorMessage()`
  The return message of a failed operation.
  `SuccessType`
  `getMessage()`
  The return message of a successful operation.
  `ServiceResult<SuccessType>`
  `ifSuccessful(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(Function<SuccessType,T> successFunction, Function<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`

  ### Methods inherited from interface org.apache.geode.services.result.ServiceResult

  `ifFailure`

- ## Field Details

  - ### SUCCESS_TRUE

    @Immutable public static final Success<Boolean> SUCCESS_TRUE

- ## Method Details

  - ### 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(Function<SuccessType,T> successFunction, Function<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,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`

  - ### getMessage

    public SuccessType getMessage()
    Description copied from interface: `Result`
    The return message of a successful operation. The return type is of type `SuccessType`
    Specified by:
      `getMessage` in interface `Result<SuccessType,String>`
    Specified by:
      `getMessage` in interface `ServiceResult<SuccessType>`
    Returns:
      the result of the operation

  - ### getErrorMessage

    public 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,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,String>`
    Returns:
      true indicating the success of the operation

  - ### ifSuccessful

    public ServiceResult<SuccessType> ifSuccessful(Consumer<? super SuccessType> consumer)
    Description copied from interface: `ServiceResult`
    Executes the provided `Consumer` if this `ServiceResult` is a success.
    Specified by:
      `ifSuccessful` in interface `ServiceResult<SuccessType>`
    Parameters:
      `consumer` - the `Consumer` to be executed on success.
    Returns:
      this `ServiceResult`