public abstract class GuavaCompatibility extends Object
The driver is compatible with Guava 16.0.1 or higher, but Guava 20 introduced incompatible breaking changes in its API, that could in turn be breaking for legacy driver clients if we simply upgraded our dependency. We don't want to increment our major version "just" for Guava (we have other changes planned).
Therefore we depend on Guava 19, which has both the deprecated and the new APIs, and detect the actual version at runtime in order to call the relevant methods.
This is a hack, and might not work with subsequent Guava releases; the real fix is to stop exposing Guava in our public API. We'll address that in version 4 of the driver.
| Modifier and Type | Field and Description | 
|---|---|
| static GuavaCompatibility | INSTANCEThe unique instance of this class, that is compatible with the Guava version found in the
 classpath. | 
| Constructor and Description | 
|---|
| GuavaCompatibility() | 
| Modifier and Type | Method and Description | 
|---|---|
| <I> void | addCallback(ListenableFuture<I> input,
           FutureCallback<? super I> callback)Registers separate success and failure callbacks to be run when the  Future's
 computation is complete or, if the
 computation is already complete, immediately. | 
| <I> void | addCallback(ListenableFuture<I> input,
           FutureCallback<? super I> callback,
           Executor executor)Registers separate success and failure callbacks to be run when the  Future's
 computation is complete or, if the
 computation is already complete, immediately. | 
| static void | init()Force the initialization of the class. | 
| abstract boolean | isSupertypeOf(TypeToken<?> target,
             TypeToken<?> argument)Returns true if  targetis a supertype ofargument. | 
| abstract Executor | sameThreadExecutor()Returns an  Executorthat runs each task in the thread that invokesexecute, as inThreadPoolExecutor.CallerRunsPolicy. | 
| <I,O> ListenableFuture<O> | transform(ListenableFuture<I> input,
         Function<? super I,? extends O> function)Returns a new  ListenableFuturewhose result is the product of applying the givenFunctionto the result of the givenFuture. | 
| <I,O> ListenableFuture<O> | transform(ListenableFuture<I> input,
         Function<? super I,? extends O> function,
         Executor executor)Returns a new  ListenableFuturewhose result is the product of applying the givenFunctionto the result of the givenFuture. | 
| abstract <I,O> ListenableFuture<O> | transformAsync(ListenableFuture<I> input,
              AsyncFunction<? super I,? extends O> function)Returns a new  ListenableFuturewhose result is asynchronously derived from the result
 of the givenFuture. | 
| abstract <I,O> ListenableFuture<O> | transformAsync(ListenableFuture<I> input,
              AsyncFunction<? super I,? extends O> function,
              Executor executor)Returns a new  ListenableFuturewhose result is asynchronously derived from the result
 of the givenFuture. | 
| abstract <V> ListenableFuture<V> | withFallback(ListenableFuture<? extends V> input,
            AsyncFunction<Throwable,V> fallback)Returns a  Futurewhose result is taken from the given primaryinputor, if the
 primary input fails, from theFutureprovided by thefallback. | 
| abstract <V> ListenableFuture<V> | withFallback(ListenableFuture<? extends V> input,
            AsyncFunction<Throwable,V> fallback,
            Executor executor)Returns a  Futurewhose result is taken from the given primaryinputor, if the
 primary input fails, from theFutureprovided by thefallback. | 
public static final GuavaCompatibility INSTANCE
public static void init()
Cluster class).public abstract <V> ListenableFuture<V> withFallback(ListenableFuture<? extends V> input, AsyncFunction<Throwable,V> fallback)
Future whose result is taken from the given primary input or, if the
 primary input fails, from the Future provided by the fallback.public abstract <V> ListenableFuture<V> withFallback(ListenableFuture<? extends V> input, AsyncFunction<Throwable,V> fallback, Executor executor)
Future whose result is taken from the given primary input or, if the
 primary input fails, from the Future provided by the fallback.public <I> void addCallback(ListenableFuture<I> input, FutureCallback<? super I> callback)
Future's
 computation is complete or, if the
 computation is already complete, immediately.
 The callback is run in sameThreadExecutor().
public <I> void addCallback(ListenableFuture<I> input, FutureCallback<? super I> callback, Executor executor)
Future's
 computation is complete or, if the
 computation is already complete, immediately.public <I,O> ListenableFuture<O> transform(ListenableFuture<I> input, Function<? super I,? extends O> function)
ListenableFuture whose result is the product of applying the given Function to the result of the given Future.
 The callback is run in sameThreadExecutor().
public <I,O> ListenableFuture<O> transform(ListenableFuture<I> input, Function<? super I,? extends O> function, Executor executor)
ListenableFuture whose result is the product of applying the given Function to the result of the given Future.public abstract <I,O> ListenableFuture<O> transformAsync(ListenableFuture<I> input, AsyncFunction<? super I,? extends O> function)
ListenableFuture whose result is asynchronously derived from the result
 of the given Future. More precisely, the returned Future takes its result from
 a Future produced by applying the given AsyncFunction to the result of the
 original Future.public abstract <I,O> ListenableFuture<O> transformAsync(ListenableFuture<I> input, AsyncFunction<? super I,? extends O> function, Executor executor)
ListenableFuture whose result is asynchronously derived from the result
 of the given Future. More precisely, the returned Future takes its result from
 a Future produced by applying the given AsyncFunction to the result of the
 original Future.public abstract boolean isSupertypeOf(TypeToken<?> target, TypeToken<?> argument)
target is a supertype of argument. "Supertype" is defined
 according to the rules for type arguments introduced with Java generics.public abstract Executor sameThreadExecutor()
Executor that runs each task in the thread that invokes execute, as in ThreadPoolExecutor.CallerRunsPolicy.Copyright © 2012–2025. All rights reserved.