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 |
INSTANCE
The 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. |
String |
getHost(HostAndPort hostAndPort)
Returns the portion of the given
HostAndPort instance that should represent the
hostname or IPv4/IPv6 literal. |
static void |
init()
Force the initialization of the class.
|
abstract boolean |
isSupertypeOf(TypeToken<?> target,
TypeToken<?> argument)
Returns true if
target is a supertype of argument . |
abstract Executor |
sameThreadExecutor()
Returns an
Executor that runs each task in the thread that invokes execute , as in ThreadPoolExecutor.CallerRunsPolicy . |
<I,O> ListenableFuture<O> |
transform(ListenableFuture<I> input,
Function<? super I,? extends O> function)
Returns a new
ListenableFuture whose result is the product of applying the given Function to the result of the given Future . |
<I,O> ListenableFuture<O> |
transform(ListenableFuture<I> input,
Function<? super I,? extends O> function,
Executor executor)
Returns a new
ListenableFuture whose result is the product of applying the given Function to the result of the given Future . |
abstract <I,O> ListenableFuture<O> |
transformAsync(ListenableFuture<I> input,
AsyncFunction<? super I,? extends O> function)
Returns a new
ListenableFuture whose result is asynchronously derived from the result
of the given Future . |
abstract <I,O> ListenableFuture<O> |
transformAsync(ListenableFuture<I> input,
AsyncFunction<? super I,? extends O> function,
Executor executor)
Returns a new
ListenableFuture whose result is asynchronously derived from the result
of the given Future . |
abstract <V> ListenableFuture<V> |
withFallback(ListenableFuture<? extends V> input,
AsyncFunction<Throwable,V> fallback)
Returns a
Future whose result is taken from the given primary input or, if the
primary input fails, from the Future provided by the fallback . |
abstract <V> ListenableFuture<V> |
withFallback(ListenableFuture<? extends V> input,
AsyncFunction<Throwable,V> fallback,
Executor executor)
Returns a
Future whose result is taken from the given primary input or, if the
primary input fails, from the Future provided by the fallback . |
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
.public String getHost(HostAndPort hostAndPort)
HostAndPort
instance that should represent the
hostname or IPv4/IPv6 literal.
The method HostAndPort.getHostText
has been replaced with HostAndPort.getHost
starting with Guava 20.0; it has been completely removed in Guava 22.0.
Copyright © 2012–2024. All rights reserved.