Package com.ocient.util
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 Summary
Modifier and TypeMethodDescriptionstatic <T> CompletableFutures.SQLResult<T>fail(SQLException e) Creates a new instance ofSQLResultthat represents a failed execution of a SQL query.static <T> CompletionStage<CompletableFutures.SQLResult<T>>Creates a new completed stage that represents a failed execution of a SQL query.static <T> CompletableFutures.SQLResult<T>failOrMarshal(Throwable throwable) Returns a new Result object that represents a failed operation with the givenSQLException.static <T> CompletionStage<CompletableFutures.SQLResult<T>>failOrMarshalAsync(Throwable throwable) Returns a new completed stage that represents a failed operation with the givenSQLException.default <U> CompletableFutures.SQLResult<U>flatMapSuccess(Function<? super T, ? extends CompletableFutures.SQLResult<U>> fn) Maps the success value of this SQLResult to theCompletableFutures.SQLResulttype returned from the given function.default intReturns the error code associated with theSQLExceptiondefault SQLExceptionReturns the fail cause.default booleanReturns true if the operation returned a warning, and false otherwise.default <U> CompletableFutures.SQLResult<U>mapSuccess(Function<? super T, ? extends U> fn) Maps the success value of this Result to a new Result of a different type by applying the given function.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 differentCompletableFutures.SQLResulttype by applying the given function.default CompletionStage<CompletableFutures.SQLResult<T>>recoverAsync(Function<? super SQLException, ? extends CompletionStage<CompletableFutures.SQLResult<T>>> fn) Maps the error value of this SQLResult to a new completion stage that completes with a new SQLResult by applying the given function.static <T> CompletableFutures.SQLResult<T>success(T item) Creates a new instance ofSQLResultthat represents a successful execution of a SQL query.static <T> CompletionStage<CompletableFutures.SQLResult<T>>successAsync(T item) Creates a new completed stage that represents a successful execution of a SQL query.Returns aCompletionStagethat completes successfully with aCompletableFutures.SQLResultthat represents a successful execution of a SQL query that does not produce a result.static CompletableFutures.SQLResult<Void>Returns aCompletableFutures.SQLResultthat represents a successful execution of a SQL query that does not produce a result.Methods inherited from interface com.ocient.util.CompletableFutures.Result
equals, get, isException, isSuccess, orElseThrow, recoverMethods inherited from interface com.ibm.asyncutil.util.Either
flatMap, fold, forEach, isLeft, isRight, left, map, map, right
-
Method Details
-
voidResult
Returns aCompletableFutures.SQLResultthat represents a successful execution of a SQL query that does not produce a result.- Type Parameters:
T- the type of the result (which is alwaysVoid- Returns:
- a
SQLResultthat represents a successful execution of a SQL query that does not produce a result
-
voidFuture
Returns aCompletionStagethat completes successfully with aCompletableFutures.SQLResultthat represents a successful execution of a SQL query that does not produce a result.- Type Parameters:
T- the type of the result (which is alwaysVoid- Returns:
- a
CompletionStagethat completes successfully with aSQLResultthat represents a successful execution of a SQL query that does not produce a result
-
mapSuccess
Description copied from interface:CompletableFutures.ResultMaps 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:
mapSuccessin interfaceCompletableFutures.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 differentCompletableFutures.SQLResulttype 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 theCompletableFutures.SQLResulttype 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
Description copied from interface:CompletableFutures.ResultReturns the fail cause. If this Result represents success, anSQLStates.OKis returned.- Specified by:
getExceptionin interfaceCompletableFutures.Result<T,SQLException> - Returns:
- the fail cause or
SQLStates.OKif success
-
getErrorCode
default int getErrorCode()Returns the error code associated with theSQLException -
success
Creates a new instance ofSQLResultthat 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
SQLResultthat represents a successful execution of a SQL query
-
fail
Creates a new instance ofSQLResultthat 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 ofSQLException- Returns:
- a new instance of
SQLResultthat represents a failed execution of a SQL query
-
successAsync
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
SQLResultthat 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 ofSQLException- Returns:
- a new
CompletionStagethat represents a failed execution of a SQL query
-
failOrMarshal
Returns a new Result object that represents a failed operation with the givenSQLException.- Type Parameters:
T- the type of the success value (unused in this case)- Parameters:
throwable- theSQLExceptionthat caused the failure- Returns:
- a new Result object that represents a failed operation with the given
SQLException
-
failOrMarshalAsync
Returns a new completed stage that represents a failed operation with the givenSQLException.- Type Parameters:
T- the type of the success value (unused in this case)- Parameters:
throwable- theSQLExceptionthat caused the failure- Returns:
- a new
CompletionStagethat represents a failed operation with the givenSQLException
-
recoverAsync
default CompletionStage<CompletableFutures.SQLResult<T>> recoverAsync(Function<? super SQLException, ? extends CompletionStage<CompletableFutures.SQLResult<T>>> fn) 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
-