Interface CompletableFutures.SQLResult<T>

Type Parameters:
T - the type of the result
All Superinterfaces:
CompletableFutures.Result<T,SQLException>, com.ibm.asyncutil.util.Either<T,SQLException>
Enclosing class:
CompletableFutures

public static interface CompletableFutures.SQLResult<T> extends CompletableFutures.Result<T,SQLException>
A specialization of the CompletableFutures.Result interface that represents the result of executing a SQL query.
  • Method Details

    • voidResult

      static CompletableFutures.SQLResult<Void> voidResult()
      Returns a CompletableFutures.SQLResult that represents a successful execution of a SQL query that does not produce a result.
      Type Parameters:
      T - the type of the result (which is always Void
      Returns:
      a SQLResult that represents a successful execution of a SQL query that does not produce a result
    • voidFuture

      Returns a CompletionStage that completes successfully with a CompletableFutures.SQLResult that represents a successful execution of a SQL query that does not produce a result.
      Type Parameters:
      T - the type of the result (which is always Void
      Returns:
      a CompletionStage that completes successfully with a SQLResult that represents a successful execution of a SQL query that does not produce a result
    • mapSuccess

      default <U> CompletableFutures.SQLResult<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,SQLException>
      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
    • mapSuccessAsync

      default <U> CompletionStage<CompletableFutures.SQLResult<U>> mapSuccessAsync(Function<? super T,? extends CompletionStage<CompletableFutures.SQLResult<U>>> fn)
      Maps the success value of this Result to a new completed stage of a different CompletableFutures.SQLResult 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
    • flatMapSuccess

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

      default boolean isWarning()
      Returns true if the operation returned a warning, and false otherwise.
      Returns:
      true if the operation returned a warning, and false otherwise
    • getException

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

      default int getErrorCode()
      Returns the error code associated with the SQLException
    • success

      static <T> CompletableFutures.SQLResult<T> success(T item)
      Creates a new instance of SQLResult that represents a successful execution of a SQL query.
      Type Parameters:
      T - the type of the result
      Parameters:
      item - the result of the query
      Returns:
      a new instance of SQLResult that represents a successful execution of a SQL query
    • fail

      static <T> CompletableFutures.SQLResult<T> fail(SQLException e)
      Creates a new instance of SQLResult that represents a failed execution of a SQL query.
      Type Parameters:
      T - the type of the result
      Parameters:
      e - the cause of the failure as an instance of SQLException
      Returns:
      a new instance of SQLResult that represents a failed execution of a SQL query
    • successAsync

      static <T> CompletionStage<CompletableFutures.SQLResult<T>> successAsync(T item)
      Creates a new completed stage that represents a successful execution of a SQL query.
      Type Parameters:
      T - the type of the result
      Parameters:
      item - the result of the query
      Returns:
      a new instance of SQLResult that represents a successful execution of a SQL query
    • failAsync

      Creates a new completed stage that represents a failed execution of a SQL query.
      Type Parameters:
      T - the type of the result
      Parameters:
      e - the cause of the failure as an instance of SQLException
      Returns:
      a new CompletionStage that represents a failed execution of a SQL query
    • failOrMarshal

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

      static <T> CompletionStage<CompletableFutures.SQLResult<T>> failOrMarshalAsync(Throwable throwable)
      Returns a new completed stage that represents a failed operation with the given SQLException.
      Type Parameters:
      T - the type of the success value (unused in this case)
      Parameters:
      throwable - the SQLException that caused the failure
      Returns:
      a new CompletionStage that represents a failed operation with the given SQLException
    • recoverAsync

      Maps the error value of this SQLResult to a new completion stage that completes with a new SQLResult by applying the given function. If this result represents a success, the returned stage will complete with the result.
      Parameters:
      fn - the function to apply to the error value