Package com.ocient.util
Interface CompletableFutures.Result<T,E extends Exception>
- Type Parameters:
T- the type of the success value
- All Superinterfaces:
com.ibm.asyncutil.util.Either<T,E>
- All Known Subinterfaces:
CompletableFutures.IOResult<T>,CompletableFutures.SQLResult<T>,TransportResult<T>
- All Known Implementing Classes:
CompletableFutures.FailedResult,CompletableFutures.SuccessResult,TransportResult.FailedTransportResult,TransportResult.SuccessTransportResult
- Enclosing class:
CompletableFutures
public static interface CompletableFutures.Result<T,E extends Exception>
extends com.ibm.asyncutil.util.Either<T,E>
A Result represents the result of a operation that can either succeed with a value of type T,
or fail with a SQLException.
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanequals(CompletableFutures.Result<T, E> other) Equality operator forCompletableFutures.SQLResult.default Tget()Returns the success result reason.default EReturns the fail cause.default booleanReturns true if the operation failed, and false otherwise.default booleanReturns true if the operation was successful, and false otherwise.default <U> CompletableFutures.Result<U, E> 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 TReturns the success value of this Result.default TMaps the error value of this Result to a new success value by applying the given function.static <E extends Exception>
CompletionStage<CompletableFutures.Result<Void, E>> Returns aCompletionStagethat completes successfully with aCompletableFutures.Resultthat represents a successful execution of an operation that does not produce a result.static <E extends Exception>
CompletableFutures.Result<Void, E> Returns aCompletableFutures.Resultthat represents a successful execution of an operation that does not produce a result.Methods inherited from interface com.ibm.asyncutil.util.Either
flatMap, fold, forEach, isLeft, isRight, left, map, map, right
-
Method Details
-
voidResult
Returns aCompletableFutures.Resultthat represents a successful execution of an operation that does not produce a result.- Type Parameters:
E- the type of the exceptionT- the type of the result (which is alwaysVoid- Returns:
- a
Resultthat represents a successful execution of an operation that does not produce a result
-
voidFuture
Returns aCompletionStagethat completes successfully with aCompletableFutures.Resultthat represents a successful execution of an operation that does not produce a result.- Type Parameters:
T- the type of the result (which is alwaysVoid- Returns:
- a
CompletionStageinstance that completes successfully with aResultthat represents a successful execution of an operation that does not produce a result
-
get
Returns the success result reason. If this Result represents an error, the fail cause is thrown.- Returns:
- the fail cause
- Throws:
E- if this Result represents an error
-
getException
Returns the fail cause. If this Result represents success, anSQLStates.OKis returned.- Returns:
- the fail cause or
SQLStates.OKif success
-
orElseThrow
Returns the success value of this Result. If this Result represents an error, an IllegalStateException is thrown.- Returns:
- the success value
- Throws:
IllegalStateException- if this Result represents an error
-
isException
default boolean isException()Returns true if the operation failed, and false otherwise.- Returns:
- true if the operation failed, and false otherwise
-
isSuccess
default boolean isSuccess()Returns true if the operation was successful, and false otherwise.- Returns:
- true if the operation was successful, and false otherwise
-
mapSuccess
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.- 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
-
recover
Maps the error value of this Result to a new success value by applying the given function. If this Result represents a success, a new Result with the same success value is returned.- Parameters:
fn- the function to apply to the error value- Returns:
- a new Result with the mapped error value, or the same Result with the same success value
-
equals
Equality operator forCompletableFutures.SQLResult.
-