Class ListenableFutures
- java.lang.Object
-
- org.opendaylight.infrautils.utils.concurrent.ListenableFutures
-
public final class ListenableFutures extends Object
More static utility methods pertaining to Guava's ListenableFuture interface.- Author:
- Michael Vorburger.ch
- See Also:
Futures
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <V> void
addErrorLogging(com.google.common.util.concurrent.ListenableFuture<V> future, org.slf4j.Logger logger, String message)
Deprecated.static <V> void
addErrorLogging(com.google.common.util.concurrent.ListenableFuture<V> future, org.slf4j.Logger logger, String format, Object arg)
Deprecated.static <V> void
addErrorLogging(com.google.common.util.concurrent.ListenableFuture<V> future, org.slf4j.Logger logger, String format, Object... arguments)
Deprecated.static <V,E extends Exception>
VcheckedGet(com.google.common.util.concurrent.ListenableFuture<V> future, Function<? super Exception,E> mapper)
static <V,E extends Exception>
VcheckedGet(com.google.common.util.concurrent.ListenableFuture<V> future, Function<? super Exception,E> mapper, long timeout, TimeUnit unit)
static <V> CompletionStage<V>
toCompletionStage(com.google.common.util.concurrent.ListenableFuture<V> future)
Converts a Guava ListenableFuture to a Java 8 CompletionStage.
-
-
-
Method Detail
-
toCompletionStage
public static <V> CompletionStage<V> toCompletionStage(com.google.common.util.concurrent.ListenableFuture<V> future)
Converts a Guava ListenableFuture to a Java 8 CompletionStage. Callers should not cast the returned CompletionStage by this method to CompletableFuture (as it may not be one). SeeCompletionStages.toListenableFuture(CompletionStage)
for the inverse function of this. andCompletableFutures.toListenableFuture(java.util.concurrent.CompletableFuture)
for a related function.
-
addErrorLogging
@Deprecated public static <V> void addErrorLogging(com.google.common.util.concurrent.ListenableFuture<V> future, org.slf4j.Logger logger, String message)
Deprecated.Adds a callback to a ListenableFuture which logs any failures.Instead of using this helper, you should consider directly using
Futures.addCallback(ListenableFuture, com.google.common.util.concurrent.FutureCallback, java.util.concurrent.Executor)
to add a callback which does real error recovery in case of a failure instead of just logging an error, if you can.
-
addErrorLogging
@Deprecated public static <V> void addErrorLogging(com.google.common.util.concurrent.ListenableFuture<V> future, org.slf4j.Logger logger, String format, Object arg)
Deprecated.Adds a callback to a ListenableFuture which logs any failures.Instead of using this helper, you should consider directly using
Futures.addCallback(ListenableFuture, com.google.common.util.concurrent.FutureCallback, java.util.concurrent.Executor)
to add a callback which does real error recovery in case of a failure instead of just logging an error, if you can.
-
addErrorLogging
@Deprecated public static <V> void addErrorLogging(com.google.common.util.concurrent.ListenableFuture<V> future, org.slf4j.Logger logger, String format, Object... arguments)
Deprecated.Adds a callback to a ListenableFuture which logs any failures.Instead of using this helper, you should consider directly using
Futures.addCallback(ListenableFuture, com.google.common.util.concurrent.FutureCallback, java.util.concurrent.Executor)
to add a callback which does real error recovery in case of a failure instead of just logging an error, if you can.
-
checkedGet
public static <V,E extends Exception> V checkedGet(com.google.common.util.concurrent.ListenableFuture<V> future, Function<? super Exception,E> mapper) throws E extends Exception
- Throws:
E extends Exception
-
checkedGet
public static <V,E extends Exception> V checkedGet(com.google.common.util.concurrent.ListenableFuture<V> future, Function<? super Exception,E> mapper, long timeout, TimeUnit unit) throws E extends Exception, TimeoutException
- Throws:
E extends Exception
TimeoutException
-
-