Class CompletableFutures.FailedResult<T,E extends Exception>

java.lang.Object
com.ocient.util.CompletableFutures.FailedResult<T,E>
Type Parameters:
T - the type of the success value (unused in this case)
All Implemented Interfaces:
com.ibm.asyncutil.util.Either<T,E>, CompletableFutures.Result<T,E>
Direct Known Subclasses:
TransportResult.FailedTransportResult
Enclosing class:
CompletableFutures

public static class CompletableFutures.FailedResult<T,E extends Exception> extends Object implements CompletableFutures.Result<T,E>
A Result that represents a failed operation.
  • Field Details

    • exception

      protected final E extends Exception exception
  • Constructor Details

    • FailedResult

      public FailedResult(E exception)
      Constructs a new FailedResult with the given Exception.
      Parameters:
      exception - the Exception that caused the failure
  • Method Details

    • isLeft

      public boolean isLeft()
      Specified by:
      isLeft in interface com.ibm.asyncutil.util.Either<T,E extends Exception>
    • isRight

      public boolean isRight()
      Specified by:
      isRight in interface com.ibm.asyncutil.util.Either<T,E extends Exception>
    • get

      public T get() throws E
      Description copied from interface: CompletableFutures.Result
      Returns the success result reason. If this Result represents an error, the fail cause is thrown.
      Specified by:
      get in interface CompletableFutures.Result<T,E extends Exception>
      Returns:
      the fail cause
      Throws:
      E
    • orElseThrow

      public T orElseThrow()
      Description copied from interface: CompletableFutures.Result
      Returns the success value of this Result. If this Result represents an error, an IllegalStateException is thrown.
      Specified by:
      orElseThrow in interface CompletableFutures.Result<T,E extends Exception>
      Returns:
      the success value
    • getException

      public E getException()
      Description copied from interface: CompletableFutures.Result
      Returns the fail cause. If this Result represents success, an SQLStates.OK is returned.
      Specified by:
      getException in interface CompletableFutures.Result<T,E extends Exception>
      Returns:
      the fail cause or SQLStates.OK if success
    • fold

      public <V> V fold(Function<? super T,? extends V> leftFn, Function<? super E,? extends V> rightFn)
      Applies the given functions to the success value and the Exception, respectively, and returns the result of applying the Exception function.
      Specified by:
      fold in interface com.ibm.asyncutil.util.Either<T,E extends Exception>
      Parameters:
      leftFn - the function to apply to the success value (unused in this case)
      rightFn - the function to apply to the Exception
      Returns:
      the result of applying the Exception function
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Returns a string representation of this FailedResult.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this FailedResult, in the format "[exception]", where "exception" is the string representation of the underlying Exception