Package com.linecorp.armeria.common.util
Class UnmodifiableFuture<T>
java.lang.Object
java.util.concurrent.CompletableFuture<T>
com.linecorp.armeria.common.util.EventLoopCheckingFuture<T>
com.linecorp.armeria.common.util.UnmodifiableFuture<T>
- All Implemented Interfaces:
CompletionStage<T>
,Future<T>
public final class UnmodifiableFuture<T> extends EventLoopCheckingFuture<T>
A
CompletableFuture
which prevents the caller from completing it. An attempt to call any of
the following methods will trigger an UnsupportedOperationException
:
Also, cancel(boolean)
will do nothing but returning whether cancelled or not.-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture
CompletableFuture.AsynchronousCompletionTask
-
Method Summary
Modifier and Type Method Description boolean
cancel(boolean mayInterruptIfRunning)
Does nothing but returning whether this future has been cancelled or not.boolean
complete(T value)
Throws anUnsupportedOperationException
.static <U> UnmodifiableFuture<U>
completedFuture(U value)
Returns anUnmodifiableFuture
which has been completed with the specifiedvalue
.boolean
completeExceptionally(Throwable ex)
Throws anUnsupportedOperationException
.static <U> UnmodifiableFuture<U>
exceptionallyCompletedFuture(Throwable cause)
Returns anUnmodifiableFuture
which has been completed exceptionally with the specifiedThrowable
.void
obtrudeException(Throwable ex)
Throws anUnsupportedOperationException
.void
obtrudeValue(T value)
Throws anUnsupportedOperationException
.static <U> UnmodifiableFuture<U>
wrap(CompletableFuture<U> future)
Returns anUnmodifiableFuture
which will be completed when the specifiedCompletableFuture
is completed.Methods inherited from class com.linecorp.armeria.common.util.EventLoopCheckingFuture
get, get, join
Methods inherited from class java.util.concurrent.CompletableFuture
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, completeAsync, completeAsync, completedStage, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, exceptionally, exceptionallyAsync, exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync, exceptionallyComposeAsync, failedFuture, failedStage, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, minimalCompletionStage, newIncompleteFuture, orTimeout, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, toString, whenComplete, whenCompleteAsync, whenCompleteAsync
-
Method Details
-
completedFuture
Returns anUnmodifiableFuture
which has been completed with the specifiedvalue
. -
exceptionallyCompletedFuture
Returns anUnmodifiableFuture
which has been completed exceptionally with the specifiedThrowable
. -
wrap
Returns anUnmodifiableFuture
which will be completed when the specifiedCompletableFuture
is completed. -
complete
Throws anUnsupportedOperationException
.- Overrides:
complete
in classCompletableFuture<T>
-
completeExceptionally
Throws anUnsupportedOperationException
.- Overrides:
completeExceptionally
in classCompletableFuture<T>
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)Does nothing but returning whether this future has been cancelled or not. -
obtrudeValue
Throws anUnsupportedOperationException
.- Overrides:
obtrudeValue
in classCompletableFuture<T>
-
obtrudeException
Throws anUnsupportedOperationException
.- Overrides:
obtrudeException
in classCompletableFuture<T>
-