Class OperationResult<Success,Error>

java.lang.Object
com.digimarc.dms.core.OperationResult<Success,Error>
Type Parameters:
Success - Type of success value
Error - Type of error value

public class OperationResult<Success,Error> extends Object
Encapsulates a successful outcome with a value of type Success or a error with an arbitrary error of type Error.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <Error> OperationResult
    error(Error code)
    Returns an instance that encapsulates the given value as error value.
    Returns the encapsulated error if this instance represents error or null if it is success.
    Returns the encapsulated success value if this instance represents success or null if it is error.
    boolean
    Returns true if this instance represents a successful outcome.
    static <Success> OperationResult
    success(Success result)
    Returns an instance that encapsulates the given value as successful value.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • success

      public static <Success> OperationResult success(Success result)
      Returns an instance that encapsulates the given value as successful value.
      Type Parameters:
      Success - type of success value
      Parameters:
      result - success value
      Returns:
      OperationResult instance with encapsulated {result} in success
    • error

      public static <Error> OperationResult error(Error code)
      Returns an instance that encapsulates the given value as error value.
      Type Parameters:
      Error - type of error value
      Parameters:
      code - error value
      Returns:
      OperationResult instance with encapsulated {code} in error
    • isSuccessful

      public boolean isSuccessful()
      Returns true if this instance represents a successful outcome.
      Returns:
    • getResult

      public Success getResult()
      Returns the encapsulated success value if this instance represents success or null if it is error.
      Returns:
      success value
    • getError

      public Error getError()
      Returns the encapsulated error if this instance represents error or null if it is success.
      Returns: