Class FluentFutures
java.lang.Object
org.opendaylight.yangtools.util.concurrent.FluentFutures
Utility methods for working with
FluentFuture
s. This class provides methods which should really live in
Guava's, for example in Futures
, as the implementations provided by Futures.immediateFuture(Object)
and others already implement FluentFuture
and so getting a FluentFuture is a matter of pure boiler-plate.
immediateBooleanFluentFuture(boolean)
, immediateBooleanFluentFuture(Boolean)
,
immediateFalseFluentFuture()
, immediateTrueFluentFuture()
and immediateNullFluentFuture()
provide low-cardinality constants, which are generally useful to reduce allocations.
- Author:
- Robert Varga
-
Method Summary
Modifier and TypeMethodDescriptionstatic FluentFuture
<Boolean> immediateBooleanFluentFuture
(boolean result) Return aFluentFuture
which is immediately completed, reporting specifiedresult
.static FluentFuture
<Boolean> immediateBooleanFluentFuture
(Boolean result) Return aFluentFuture
which is immediately completed, reporting specifiedresult
.static <T> FluentFuture
<T> Return aFluentFuture
which is immediatelyFuture.cancel(boolean)
led.static <T> FluentFuture
<T> Return aFluentFuture
which is immediately failed, reporting specified failurecause
.static FluentFuture
<Boolean> Return aFluentFuture
which is immediately completed, reporting specifiedBoolean.TRUE
.static <T> FluentFuture
<T> immediateFluentFuture
(T result) Return aFluentFuture
which is immediately completed, reporting specifiedresult
.static <@Nullable T>
FluentFuture<T> Return aFluentFuture
which is immediately completed with anull
result.static FluentFuture
<Boolean> Return aFluentFuture
which is immediately completed, reporting specifiedBoolean.TRUE
.static <T> FluentFuture
<T> Submit aCallable
to specifiedExecutor
and return aFluentFuture
that completes with the result of theCallable
.
-
Method Details
-
immediateCancelledFluentFuture
Return aFluentFuture
which is immediatelyFuture.cancel(boolean)
led.- Returns:
- An immediately-cancelled FluentFuture.
-
immediateFailedFluentFuture
Return aFluentFuture
which is immediately failed, reporting specified failurecause
.- Parameters:
cause
- failure cause- Returns:
- An immediately-failed FluentFuture.
- Throws:
NullPointerException
- ifcause
is null
-
immediateFluentFuture
Return aFluentFuture
which is immediately completed, reporting specifiedresult
.- Parameters:
result
- result of the future- Returns:
- An immediately-completed FluentFuture.
- Throws:
NullPointerException
- ifresult
is null
-
immediateNullFluentFuture
Return aFluentFuture
which is immediately completed with anull
result.- Returns:
- An immediately-completed FluentFuture.
-
immediateBooleanFluentFuture
Return aFluentFuture
which is immediately completed, reporting specifiedresult
.- Parameters:
result
- boolean result- Returns:
- An immediately-completed FluentFuture reporting specified
result
- Throws:
NullPointerException
- ifresult
is null
-
immediateBooleanFluentFuture
Return aFluentFuture
which is immediately completed, reporting specifiedresult
.- Parameters:
result
- boolean result- Returns:
- An immediately-completed FluentFuture reporting specified
result
-
immediateTrueFluentFuture
Return aFluentFuture
which is immediately completed, reporting specifiedBoolean.TRUE
.- Returns:
- An immediately-completed FluentFuture reporting
Boolean.TRUE
-
immediateFalseFluentFuture
Return aFluentFuture
which is immediately completed, reporting specifiedBoolean.TRUE
.- Returns:
- An immediately-completed FluentFuture reporting
Boolean.TRUE
-
submit
Submit aCallable
to specifiedExecutor
and return aFluentFuture
that completes with the result of theCallable
.- Type Parameters:
T
- Callable return type- Parameters:
callable
- The Callable to callexecutor
- The Executor to use- Throws:
NullPointerException
- if any argument isnull
-