Package com.ocient.util
Interface CompletableFutures.IOResult<T>
- Type Parameters:
T- the type of the result
- All Superinterfaces:
CompletableFutures.Result<T,,IOException> com.ibm.asyncutil.util.Either<T,IOException>
- Enclosing class:
CompletableFutures
public static interface CompletableFutures.IOResult<T>
extends CompletableFutures.Result<T,IOException>
A specialization of the
CompletableFutures.Result interface that represents the result of an I/O
operation.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> CompletableFutures.IOResult<T> fail(IOException e) Creates a new instance ofIOResultthat represents a failed I/O operation.static <T> CompletionStage<CompletableFutures.IOResult<T>> Creates a new completed stage that represents a failed execution of an I/O operation.static <T> CompletableFutures.IOResult<T> failOrMarshal(Throwable throwable) Returns a new Result object that represents a failed operation with the givenIOException.static <T> CompletionStage<CompletableFutures.IOResult<T>> failOrMarshalAsync(Throwable throwable) Returns a new completed staged that represents a failed operation with the givenIOException.default <U> CompletableFutures.IOResult<U> flatMapSuccess(Function<? super T, ? extends CompletableFutures.IOResult<U>> fn) Maps the success value of this IOResult to theCompletableFutures.IOResulttype returned from the given function.default IOExceptionReturns the fail cause.default <U> CompletableFutures.IOResult<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.static <T> CompletableFutures.IOResult<T> success(T item) Creates a new instance ofIOResultthat represents a successful I/O operation.static <T> CompletionStage<CompletableFutures.IOResult<T>> successAsync(T item) Creates a new completed stage that represents a successful execution of an I/O operation.Returns aCompletionStageinstance that completes successfully with aCompletableFutures.SQLResultthat represents a successful execution of a I/O operation that does not produce a result.static CompletableFutures.IOResult<Void> Returns anCompletableFutures.IOResultthat represents a successful execution of a I/O operation 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 anCompletableFutures.IOResultthat 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 alwaysVoid- Returns:
- a
IOResultinstance that represents a successful execution of a I/O operation that does not produce a result
-
voidFuture
Returns aCompletionStageinstance that completes successfully with aCompletableFutures.SQLResultthat 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 alwaysVoid- Returns:
- a
CompletionStageinstance that completes successfully with aIOResultthat represents a successful execution of a I/O operation 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,IOException> - 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> CompletableFutures.IOResult<U> flatMapSuccess(Function<? super T, ? extends CompletableFutures.IOResult<U>> fn) Maps the success value of this IOResult to theCompletableFutures.IOResulttype returned from the given function. If this IOResult represents an error, a new IOResult with the same error is returned.- Type Parameters:
U- the type of the success value of the new IOResult- Parameters:
fn- the function which returns the new IOResult- Returns:
- a IOResult with the mapped success value, or the same IOResult with the same error
-
getException
Description copied from interface:CompletableFutures.ResultReturns the fail cause. If this Result represents success, anSQLStates.OKis returned.- Specified by:
getExceptionin interfaceCompletableFutures.Result<T,IOException> - Returns:
- the fail cause or
SQLStates.OKif success
-
success
Creates a new instance ofIOResultthat 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
IOResultthat represents a successful I/O operation
-
fail
Creates a new instance ofIOResultthat represents a failed I/O operation.- Type Parameters:
T- the type of the result- Parameters:
e- the cause of the failure as an instance ofIOException- Returns:
- a new instance of
IOResultthat represents a failed I/O operation
-
successAsync
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 query- Returns:
- a new instance of
IOResultthat represents a successful execution of an I/O operation
-
failAsync
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 ofCompletableFutures.IOResult- Returns:
- a new
CompletionStagethat represents a failed execution of an I/O operation
-
failOrMarshal
Returns a new Result object that represents a failed operation with the givenIOException.- Type Parameters:
T- the type of the success value (unused in this case)- Parameters:
throwable- theIOExceptionthat caused the failure- Returns:
- a new Result object that represents a failed operation with the given
IOException
-
failOrMarshalAsync
Returns a new completed staged that represents a failed operation with the givenIOException.- Type Parameters:
T- the type of the success value (unused in this case)- Parameters:
throwable- theIOExceptionthat caused the failure- Returns:
- a new CompletionStage object that represents a failed operation with the given
IOException
-