Package com.ocient.transport
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
A specialization of the
CompletableFutures.Result interface that represents the result of an I/O operation.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TransportResult<?> static final CompletionStage<? extends TransportResult<?>> -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TransportResult<T> Creates a new instance ofTransportResultthat represents a failed I/O operation.static <T> CompletionStage<TransportResult<T>> Creates a new completed stage that represents a failed execution of an I/O operation.static <T> TransportResult<T> failOrMarshal(Throwable throwable) Returns a new Result object that represents a failed operation with the givenIOException.static <T> CompletionStage<TransportResult<T>> failOrMarshalAsync(Throwable throwable) Returns a new completed staged that represents a failed operation with the givenIOException.static <T> TransportResult<T> Creates a new instance ofTransportResultthat represents a failed send operation.static <T> CompletionStage<TransportResult<T>> Creates a new completed stage that represents a failed execution of an I/O operation.static <T> TransportResult<T> Creates a new instance ofTransportResultthat represents a failed send operation.static <T> CompletionStage<TransportResult<T>> Creates a new completed stage that represents a failed execution of an I/O operation.default <U> TransportResult<U> flatMapSuccess(Function<? super T, ? extends TransportResult<U>> fn) Maps the success value of this TransportResult to theTransportResulttype returned from the given function.default TransportExceptionReturns the fail cause.default <U> TransportResult<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<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 differentTransportResulttype by applying the given function.static <T> TransportResult<T> success(T item) Creates a new instance ofTransportResultthat represents a successful I/O operation.static <T> CompletionStage<TransportResult<T>> successAsync(T item) Creates a new completed stage that represents a successful execution of an I/O operation.static CompletionStage<TransportResult<Void>> Returns aCompletionStageinstance that completes successfully with aCompletableFutures.SQLResultthat represents a successful execution of a I/O operation that does not produce a result.static TransportResult<Void> Returns anTransportResultthat 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
-
Field Details
-
VOID_TRANSPORT_RESULT
-
VOID_TRANSPORT_RESULT_FUTURE
-
-
Method Details
-
voidResult
Returns anTransportResultthat 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
TransportResultinstance 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 aTransportResultthat 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,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
Maps the success value of this TransportResult to theTransportResulttype 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
Description copied from interface:CompletableFutures.ResultReturns the fail cause. If this Result represents success, anSQLStates.OKis returned.- Specified by:
getExceptionin interfaceCompletableFutures.Result<T,TransportException> - Returns:
- the fail cause or
SQLStates.OKif success
-
success
Creates a new instance ofTransportResultthat 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
TransportResultthat represents a successful 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 operation- Returns:
- a new instance of
TransportResult
-
fail
Creates a new instance ofTransportResultthat represents a failed I/O operation.- Type Parameters:
T- the type of the result- Parameters:
e- the cause of the failure as an instance ofTransportException- Returns:
- a new instance of
TransportResultthat represents a failed I/O operation
-
failSend
Creates a new instance ofTransportResultthat represents a failed send operation.- Type Parameters:
T- the type of the result- Parameters:
e- the cause of the failure as an instance ofException- Returns:
- a new instance of
TransportResultthat represents a failed SEND operation
-
failRecv
Creates a new instance ofTransportResultthat represents a failed send operation.- Type Parameters:
T- the type of the result- Parameters:
e- the cause of the failure as an instance ofException- Returns:
- a new instance of
TransportResultthat represents a failed RECV 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 ofTransportResult- Returns:
- a new
CompletionStagethat represents a failed execution of an I/O operation
-
failSendAsync
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 ofTransportResult- Returns:
- a new
CompletionStagethat represents a failed execution of an I/O operation
-
failRecvAsync
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 ofTransportResult- Returns:
- a new
CompletionStagethat 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 differentTransportResulttype 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
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
-