Interface TransportResult<T>

Type Parameters:
T - the type of the result
All Superinterfaces:
CompletableFutures.Result<T,TransportException>, com.ibm.asyncutil.util.Either<T,TransportException>
All Known Implementing Classes:
TransportResult.FailedTransportResult, TransportResult.SuccessTransportResult

public interface TransportResult<T> extends CompletableFutures.Result<T,TransportException>
A specialization of the CompletableFutures.Result interface that represents the result of an I/O operation.
  • Field Details

  • Method Details

    • voidResult

      static TransportResult<Void> voidResult()
      Returns an TransportResult that represents a successful execution of a I/O operation that does not produce a result.
      Type Parameters:
      T - the type of the result (which is always Void
      Returns:
      a TransportResult instance that represents a successful execution of a I/O operation that does not produce a result
    • voidFuture

      static CompletionStage<TransportResult<Void>> voidFuture()
      Returns a CompletionStage instance that completes successfully with a CompletableFutures.SQLResult that represents a successful execution of a I/O operation that does not produce a result.
      Type Parameters:
      T - the type of the result (which is always Void
      Returns:
      a CompletionStage instance that completes successfully with a TransportResult that represents a successful execution of a I/O operation that does not produce a result
    • mapSuccess

      default <U> TransportResult<U> mapSuccess(Function<? super T,? extends U> fn)
      Description copied from interface: CompletableFutures.Result
      Maps the success value of this Result to a new Result of a different type by applying the given function. If this Result represents an error, a new Result with the same error is returned.
      Specified by:
      mapSuccess in interface CompletableFutures.Result<T,TransportException>
      Type Parameters:
      U - the type of the success value of the new Result
      Parameters:
      fn - the function to apply to the success value
      Returns:
      a new Result with the mapped success value, or the same Result with the same error
    • flatMapSuccess

      default <U> TransportResult<U> flatMapSuccess(Function<? super T,? extends TransportResult<U>> fn)
      Maps the success value of this TransportResult to the TransportResult type returned from the given function. If this TransportResult represents an error, a new TransportResult with the same error is returned.
      Type Parameters:
      U - the type of the success value of the new TransportResult
      Parameters:
      fn - the function which returns the new TransportResult
      Returns:
      a TransportResult with the mapped success value, or the same TransportResult with the same error
    • getException

      default TransportException 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,TransportException>
      Returns:
      the fail cause or SQLStates.OK if success
    • success

      static <T> TransportResult<T> success(T item)
      Creates a new instance of TransportResult that represents a successful I/O operation.
      Type Parameters:
      T - the type of the result
      Parameters:
      item - the result of the operation
      Returns:
      a new instance of TransportResult that represents a successful I/O operation
    • successAsync

      static <T> CompletionStage<TransportResult<T>> successAsync(T item)
      Creates a new completed stage that represents a successful execution of an I/O operation.
      Type Parameters:
      T - the type of the result
      Parameters:
      item - the result of the operation
      Returns:
      a new instance of TransportResult
    • fail

      static <T> TransportResult<T> fail(TransportException e)
      Creates a new instance of TransportResult that represents a failed I/O operation.
      Type Parameters:
      T - the type of the result
      Parameters:
      e - the cause of the failure as an instance of TransportException
      Returns:
      a new instance of TransportResult that represents a failed I/O operation
    • failSend

      static <T> TransportResult<T> failSend(Throwable e)
      Creates a new instance of TransportResult that represents a failed send operation.
      Type Parameters:
      T - the type of the result
      Parameters:
      e - the cause of the failure as an instance of Exception
      Returns:
      a new instance of TransportResult that represents a failed SEND operation
    • failRecv

      static <T> TransportResult<T> failRecv(Throwable e)
      Creates a new instance of TransportResult that represents a failed send operation.
      Type Parameters:
      T - the type of the result
      Parameters:
      e - the cause of the failure as an instance of Exception
      Returns:
      a new instance of TransportResult that represents a failed RECV operation
    • failAsync

      static <T> CompletionStage<TransportResult<T>> failAsync(TransportException e)
      Creates a new completed stage that represents a failed execution of an I/O operation.
      Type Parameters:
      T - the type of the result
      Parameters:
      e - the cause of the failure as an instance of TransportResult
      Returns:
      a new CompletionStage that represents a failed execution of an I/O operation
    • failSendAsync

      static <T> CompletionStage<TransportResult<T>> failSendAsync(TransportException e)
      Creates a new completed stage that represents a failed execution of an I/O operation.
      Type Parameters:
      T - the type of the result
      Parameters:
      e - the cause of the failure as an instance of TransportResult
      Returns:
      a new CompletionStage that represents a failed execution of an I/O operation
    • failRecvAsync

      static <T> CompletionStage<TransportResult<T>> failRecvAsync(TransportException e)
      Creates a new completed stage that represents a failed execution of an I/O operation.
      Type Parameters:
      T - the type of the result
      Parameters:
      e - the cause of the failure as an instance of TransportResult
      Returns:
      a new CompletionStage that represents a failed execution of an I/O operation
    • mapSuccessAsync

      default <U> CompletionStage<TransportResult<U>> mapSuccessAsync(Function<? super T,? extends CompletionStage<TransportResult<U>>> fn)
      Maps the success value of this Result to a new completed stage of a different TransportResult type by applying the given function. If this Result represents an error, a new Result with the same error is returned.
      Type Parameters:
      U - the type of the success value of the new Result
      Parameters:
      fn - the function to apply to the success value
      Returns:
      a completion stage with the mapped success value, or the same Result with the same error
    • failOrMarshal

      static <T> TransportResult<T> failOrMarshal(Throwable throwable)
      Returns a new Result object that represents a failed operation with the given IOException.
      Type Parameters:
      T - the type of the success value (unused in this case)
      Parameters:
      throwable - the IOException that caused the failure
      Returns:
      a new Result object that represents a failed operation with the given IOException
    • failOrMarshalAsync

      static <T> CompletionStage<TransportResult<T>> failOrMarshalAsync(Throwable throwable)
      Returns a new completed staged that represents a failed operation with the given IOException.
      Type Parameters:
      T - the type of the success value (unused in this case)
      Parameters:
      throwable - the IOException that caused the failure
      Returns:
      a new CompletionStage object that represents a failed operation with the given IOException