| Modifier and Type | Method and Description |
|---|---|
java.time.Duration |
Stopwatch.elapsed()
Returns the current elapsed time shown on this stopwatch as a
Duration. |
static <X extends Throwable> |
Throwables.getCauseAs(Throwable throwable,
Class<X> expectedCauseType)
Returns
throwable's cause, cast to expectedCauseType. |
static String |
Throwables.getStackTraceAsString(Throwable throwable)
Returns a string containing the result of
toString(), followed by
the full, recursive stack trace of throwable. |
static List<StackTraceElement> |
Throwables.lazyStackTrace(Throwable throwable)
Returns the stack trace of
throwable, possibly providing slower iteration over the full
trace but faster iteration over parts of the trace. |
static boolean |
Throwables.lazyStackTraceIsLazy()
Returns whether
Throwables.lazyStackTrace(java.lang.Throwable) will use the special implementation described in its
documentation. |
static RuntimeException |
Throwables.propagate(Throwable throwable)
Deprecated.
Use
throw e or throw new RuntimeException(e) directly, or use a
combination of Throwables.throwIfUnchecked(java.lang.Throwable) and throw new RuntimeException(e). For
background on the deprecation, read Why we deprecated
Throwables.propagate. |
static <X extends Throwable> |
Throwables.propagateIfInstanceOf(@Nullable Throwable throwable,
Class<X> declaredType)
Deprecated.
Use
Throwables.throwIfInstanceOf(java.lang.Throwable, java.lang.Class<X>), which has the same behavior but rejects null. |
static void |
Throwables.propagateIfPossible(@Nullable Throwable throwable)
Deprecated.
Use
Throwables.throwIfUnchecked(java.lang.Throwable), which has the same behavior but rejects null. |
static <X extends Throwable> |
Throwables.propagateIfPossible(@Nullable Throwable throwable,
Class<X> declaredType)
Propagates
throwable exactly as-is, if and only if it is an instance of RuntimeException, Error, or declaredType. |
static <X1 extends Throwable,X2 extends Throwable> |
Throwables.propagateIfPossible(@Nullable Throwable throwable,
Class<X1> declaredType1,
Class<X2> declaredType2)
Propagates
throwable exactly as-is, if and only if it is an instance of RuntimeException, Error, declaredType1, or declaredType2. |
static <X extends Throwable> |
Throwables.throwIfInstanceOf(Throwable throwable,
Class<X> declaredType)
Throws
throwable if it is an instance of declaredType. |
| Modifier and Type | Method and Description |
|---|---|
CacheBuilder<K,V> |
CacheBuilder.expireAfterAccess(java.time.Duration duration)
Specifies that each entry should be automatically removed from the cache once a fixed duration
has elapsed after the entry's creation, the most recent replacement of its value, or its last
access.
|
CacheBuilder<K,V> |
CacheBuilder.expireAfterWrite(java.time.Duration duration)
Specifies that each entry should be automatically removed from the cache once a fixed duration
has elapsed after the entry's creation, or the most recent replacement of its value.
|
CacheBuilder<K,V> |
CacheBuilder.maximumWeight(long maximumWeight)
Specifies the maximum weight of entries the cache may contain.
|
CacheBuilder<K,V> |
CacheBuilder.refreshAfterWrite(java.time.Duration duration)
Specifies that active entries are eligible for automatic refresh once a fixed duration has
elapsed after the entry's creation, or the most recent replacement of its value.
|
CacheBuilder<K,V> |
CacheBuilder.refreshAfterWrite(long duration,
TimeUnit unit)
Specifies that active entries are eligible for automatic refresh once a fixed duration has
elapsed after the entry's creation, or the most recent replacement of its value.
|
ListenableFuture<V> |
CacheLoader.reload(K key,
V oldValue)
Computes or retrieves a replacement value corresponding to an already-cached
key. |
CacheBuilder<K,V> |
CacheBuilder.softValues()
Specifies that each value (not key) stored in the cache should be wrapped in a
SoftReference (by default, strong references are used). |
CacheBuilder<K,V> |
CacheBuilder.weakKeys()
Specifies that each key (not value) stored in the cache should be wrapped in a
WeakReference (by default, strong references are used). |
CacheBuilder<K,V> |
CacheBuilder.weakValues()
Specifies that each value (not key) stored in the cache should be wrapped in a
WeakReference (by default, strong references are used). |
<K1 extends K,V1 extends V> |
CacheBuilder.weigher(Weigher<? super K1,? super V1> weigher)
Specifies the weigher to use in determining the weight of entries.
|
| Modifier and Type | Method and Description |
|---|---|
static <T> T[] |
ObjectArrays.concat(T[] first,
T[] second,
Class<T> type)
Returns a new array that contains the concatenated contents of two arrays.
|
static <E> int |
Queues.drain(BlockingQueue<E> q,
Collection<? super E> buffer,
int numElements,
long timeout,
TimeUnit unit)
Drains the queue as
BlockingQueue.drainTo(Collection, int), but if the requested numElements elements are not available, it will wait for them up to the specified timeout. |
static <E> int |
Queues.drainUninterruptibly(BlockingQueue<E> q,
Collection<? super E> buffer,
int numElements,
long timeout,
TimeUnit unit)
Drains the queue as Queues.drain(BlockingQueue, Collection, int, long, TimeUnit), but
with a different behavior in case it is interrupted while waiting.
|
static <T> T[] |
ObjectArrays.newArray(Class<T> type,
int length)
Returns a new array of the given length with the specified component type.
|
static <E> ArrayBlockingQueue<E> |
Queues.newArrayBlockingQueue(int capacity)
Creates an empty
ArrayBlockingQueue with the given (fixed) capacity and nonfair access
policy. |
static <E> ConcurrentLinkedQueue<E> |
Queues.newConcurrentLinkedQueue()
Creates an empty
ConcurrentLinkedQueue. |
static <E> CopyOnWriteArraySet<E> |
Sets.newCopyOnWriteArraySet()
Creates an empty
CopyOnWriteArraySet instance. |
static <E> LinkedBlockingDeque<E> |
Queues.newLinkedBlockingDeque()
Creates an empty
LinkedBlockingDeque with a capacity of Integer.MAX_VALUE. |
static <E> LinkedBlockingDeque<E> |
Queues.newLinkedBlockingDeque(int capacity)
Creates an empty
LinkedBlockingDeque with the given (fixed) capacity. |
static <E> LinkedBlockingQueue<E> |
Queues.newLinkedBlockingQueue()
Creates an empty
LinkedBlockingQueue with a capacity of Integer.MAX_VALUE. |
static <E> LinkedBlockingQueue<E> |
Queues.newLinkedBlockingQueue(int capacity)
Creates an empty
LinkedBlockingQueue with the given (fixed) capacity. |
static <E extends Comparable> |
Queues.newPriorityBlockingQueue()
Creates an empty
PriorityBlockingQueue with the ordering given by its elements' natural
ordering. |
static <E> SynchronousQueue<E> |
Queues.newSynchronousQueue()
Creates an empty
SynchronousQueue with nonfair access policy. |
| Modifier and Type | Method and Description |
|---|---|
static int |
IntMath.log10(int x,
RoundingMode mode)
Returns the base-10 logarithm of
x, rounded according to the specified rounding mode. |
static int |
IntMath.pow(int b,
int k)
Returns
b to the kth power. |
static int |
IntMath.sqrt(int x,
RoundingMode mode)
Returns the square root of
x, rounded with the specified rounding mode. |
| Modifier and Type | Class and Description |
|---|---|
class |
AbstractListeningExecutorService
Abstract
ListeningExecutorService implementation that creates ListenableFuture
instances for each Runnable and Callable submitted to it. |
interface |
ListeningExecutorService
An
ExecutorService that returns ListenableFuture instances. |
interface |
ListeningScheduledExecutorService
A
ScheduledExecutorService that returns ListenableFuture instances from its
ExecutorService methods. |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
Uninterruptibles.awaitUninterruptibly(Condition condition,
long timeout,
TimeUnit unit)
Invokes
condition.await(timeout, unit)
uninterruptibly. |
static void |
Uninterruptibles.awaitUninterruptibly(CountDownLatch latch)
Invokes
latch.await() uninterruptibly. |
static boolean |
Uninterruptibles.awaitUninterruptibly(CountDownLatch latch,
long timeout,
TimeUnit unit)
Invokes
latch.await(timeout, unit)
uninterruptibly. |
static <V> V |
Uninterruptibles.getUninterruptibly(Future<V> future,
long timeout,
TimeUnit unit)
Invokes
future.get(timeout, unit) uninterruptibly. |
static void |
Uninterruptibles.joinUninterruptibly(Thread toJoin)
Invokes
toJoin.join() uninterruptibly. |
static void |
Uninterruptibles.joinUninterruptibly(Thread toJoin,
long timeout,
TimeUnit unit)
Invokes
unit.timedJoin(toJoin, timeout)
uninterruptibly. |
static ListeningExecutorService |
MoreExecutors.newDirectExecutorService()
Creates an executor service that runs each task in the thread that invokes
execute/submit, as in ThreadPoolExecutor.CallerRunsPolicy This applies both to individually submitted
tasks and to collections of tasks submitted via invokeAll or invokeAny. |
static ThreadFactory |
MoreExecutors.platformThreadFactory()
Returns a default thread factory used to create new threads.
|
static <E> void |
Uninterruptibles.putUninterruptibly(BlockingQueue<E> queue,
E element)
Invokes
queue.put(element) uninterruptibly. |
static boolean |
MoreExecutors.shutdownAndAwaitTermination(ExecutorService service,
long timeout,
TimeUnit unit)
Shuts down the given executor service gradually, first disabling new submissions and later, if
necessary, cancelling remaining tasks.
|
static void |
Uninterruptibles.sleepUninterruptibly(long sleepFor,
TimeUnit unit)
Invokes
unit.sleep(sleepFor) uninterruptibly. |
static <E> E |
Uninterruptibles.takeUninterruptibly(BlockingQueue<E> queue)
Invokes
queue.take() uninterruptibly. |
static boolean |
Uninterruptibles.tryAcquireUninterruptibly(Semaphore semaphore,
int permits,
long timeout,
TimeUnit unit)
Invokes
semaphore.tryAcquire(permits,
timeout, unit) uninterruptibly. |
static boolean |
Uninterruptibles.tryAcquireUninterruptibly(Semaphore semaphore,
long timeout,
TimeUnit unit)
Invokes
semaphore.tryAcquire(1,
timeout, unit) uninterruptibly. |
static <V> ListenableFuture<V> |
Futures.withTimeout(ListenableFuture<V> delegate,
long time,
TimeUnit unit,
ScheduledExecutorService scheduledExecutor)
Returns a future that delegates to another but will finish early (via a
TimeoutException wrapped in an ExecutionException) if the specified duration expires. |
FluentFuture<V> |
FluentFuture.withTimeout(long timeout,
TimeUnit unit,
ScheduledExecutorService scheduledExecutor)
Returns a future that delegates to this future but will finish early (via a
TimeoutException wrapped in an ExecutionException) if the specified timeout expires. |
Copyright © 2007-2022. All Rights Reserved.