Class Result<E extends Throwable,T>

java.lang.Object
com.atlassian.bamboo.utils.fage.Result<E,T>
Type Parameters:
E - exception type
T - result type

@PublicApi public class Result<E extends Throwable,T> extends Object
Formalized encapsulation of Either to return either result or exception.
  • Method Details

    • hasException

      public boolean hasException()
      Test if Result object holds an exception
      Returns:
      true if this Result object holds an exception
    • getResult

      public T getResult()
      Return valid result object if Result object was created with one.
      Returns:
      valid result object
      Throws:
      NoSuchElementException - if Result object was created with exception
    • getResult

      @Nullable public T getResult(@Nullable T defaultValue)
    • getException

      public E getException()
      Return exception object if Result object was created with one.
      Returns:
      exception object
      Throws:
      NoSuchElementException - if Result object was created with valid result
    • getResultThrowException

      public T getResultThrowException() throws E
      Throws:
      E extends Throwable
    • result

      public static <E extends Throwable, T> Result<E,T> result(T result)
      Create Result object with valid result object
      Type Parameters:
      E - exception type
      T - valid result type
      Parameters:
      result - valid result object
      Returns:
      Result object
    • exception

      public static <E extends Throwable, T> Result<E,T> exception(E exception)
      Create Result object with exception object
      Type Parameters:
      E - exception type
      T - valid result type
      Parameters:
      exception - exception object
      Returns:
      Result object