| Package | Description |
|---|---|
| com.google.common.base |
Basic utility libraries and interfaces.
|
| com.google.common.cache |
This package contains caching utilities.
|
| com.google.common.collect |
This package contains generic collection interfaces and implementations, and other utilities for working with collections.
|
| com.google.common.io |
This package contains utility methods and classes for working with Java I/O; for example input streams, output streams, readers, writers, and files.
|
| com.google.common.math |
Arithmetic functions operating on primitive values and
BigInteger instances.
|
| com.google.common.primitives |
Static utilities for working with the eight primitive types and
void, and value types for treating them as unsigned.
|
| com.google.common.util.concurrent |
Concurrency utilities.
|
| Modifier and Type | Class and Description |
|---|---|
class |
StandardSystemProperty
Represents a
standard system property.
|
| Modifier and Type | Field and Description |
|---|---|
static Charset |
Charsets.ISO_8859_1
ISO-8859-1: ISO Latin Alphabet Number 1 (ISO-LATIN-1).
|
static Charset |
Charsets.US_ASCII
US-ASCII: seven-bit ASCII, the Basic Latin block of the Unicode character set (ISO646-US).
|
static Charset |
Charsets.UTF_16
UTF-16: sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark.
|
static Charset |
Charsets.UTF_16BE
UTF-16BE: sixteen-bit UCS Transformation Format, big-endian byte order.
|
static Charset |
Charsets.UTF_16LE
UTF-16LE: sixteen-bit UCS Transformation Format, little-endian byte order.
|
| Modifier and Type | Method and Description |
|---|---|
static Predicate |
Predicates.assignableFrom(Class
Returns a predicate that evaluates to
true if the class being tested is assignable from the given class.
|
static Predicate |
Predicates.contains(Pattern
Returns a predicate that evaluates to
true if the
CharSequence being tested contains any match for the given regular expression pattern.
|
static Predicate |
Predicates.containsPattern(String
Returns a predicate that evaluates to
true if the
CharSequence being tested contains any match for the given regular expression pattern.
|
static Field |
Enums.getField(Enum
Returns the
Field in which
enumValue is defined.
|
static Predicate |
Predicates.instanceOf(Class
Returns a predicate that evaluates to
true if the object being tested is an instance of the given class.
|
static Splitter |
Splitter.on(Pattern
Returns a splitter that considers any subsequence matching
pattern to be a separator.
|
static Splitter |
Splitter.onPattern(String
Returns a splitter that considers any subsequence matching a given pattern (regular expression) to be a separator.
|
String |
Stopwatch.toString()
Returns a string representation of the current elapsed time.
|
| Modifier and Type | Method and Description |
|---|---|
static <K |
CacheLoader.asyncReloading(CacheLoader
Returns a
CacheLoader which wraps
loader, executing calls to
CacheLoader using
executor.
|
static CacheBuilder |
CacheBuilder.from(CacheBuilderSpec
Constructs a new
CacheBuilder instance with the settings specified in
spec.
|
static CacheBuilder |
CacheBuilder.from(String
Constructs a new
CacheBuilder instance with the settings specified in
spec.
|
CacheBuilder |
CacheBuilder.maximumWeight(long weight)
Specifies the maximum weight of entries the cache may contain.
|
CacheBuilder |
CacheBuilder.refreshAfterWrite(long duration, TimeUnit
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 |
CacheLoader.reload(K key, V oldValue)
Computes or retrieves a replacement value corresponding to an already-cached
key.
|
CacheBuilder |
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 |
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 |
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 |
CacheBuilder.weigher(Weigher
Specifies the weigher to use in determining the weight of entries.
|
| Modifier and Type | Class and Description |
|---|---|
class |
ImmutableRangeMap<K extends Comparable
A
RangeMap whose contents will never change, with many other important properties detailed at
ImmutableCollection.
|
class |
ImmutableSortedMultiset<E>
A
SortedMultiset whose contents will never change, with many other important properties detailed at
ImmutableCollection.
|
class |
TreeRangeMap<K extends Comparable
An implementation of
RangeMap based on a
TreeMap, supporting all optional operations.
|
class |
TreeRangeSet<C extends Comparable
|
| Modifier and Type | Method and Description |
|---|---|
NavigableMap |
TreeMultimap.asMap()
Returns a map view that associates each key with the corresponding values in the multimap.
|
static <K |
Maps.asMap(NavigableSet
Returns a view of the navigable set as a map, mapping keys from the set according to the specified function.
|
E |
ImmutableSortedSet.ceiling(E e)
|
static <T> T[] |
ObjectArrays.concat(T[] first, T[] second, Class
Returns a new array that contains the concatenated contents of two arrays.
|
abstract UnmodifiableIterator |
ImmutableSortedSet.descendingIterator()
|
ImmutableSortedSet |
ImmutableSortedSet.descendingSet()
|
<T> FluentIterable |
FluentIterable.filter(Class
Returns the elements from this fluent iterable that are instances of class
type.
|
static <T> Iterable |
Iterables.filter(Iterable
Returns all instances of class
type in
unfiltered.
|
static <T> UnmodifiableIterator |
Iterators.filter(Iterator
Returns all instances of class
type in
unfiltered.
|
static <E> NavigableSet |
Sets.filter(NavigableSet
Returns the elements of a
NavigableSet,
unfiltered, that satisfy a predicate.
|
static <K |
Maps.filterEntries(NavigableMap
Returns a sorted map containing the mappings in
unfiltered that satisfy a predicate.
|
static <K |
Maps.filterKeys(NavigableMap
Returns a navigable map containing the mappings in
unfiltered whose keys satisfy a predicate.
|
static <K |
Maps.filterValues(NavigableMap
Returns a navigable map containing the mappings in
unfiltered whose values satisfy a predicate.
|
E |
ImmutableSortedSet.floor(E e)
|
static ImmutableMap |
Maps.fromProperties(Properties
Creates an
ImmutableMap<String, String> from a
Properties instance.
|
NavigableSet |
TreeMultimap.get(K key)
|
ContiguousSet |
ContiguousSet.headSet(C toElement, boolean inclusive)
|
ImmutableSortedSet |
ImmutableSortedSet.headSet(E toElement, boolean inclusive)
|
E |
ImmutableSortedSet.higher(E e)
|
NavigableSet |
TreeMultimap.keySet()
Returns a view collection of all
distinct keys contained in this multimap.
|
E |
ImmutableSortedSet.lower(E e)
|
static <T> T[] |
ObjectArrays.newArray(Class
Returns a new array of the given length with the specified component type.
|
static <E> CopyOnWriteArrayList |
Lists.newCopyOnWriteArrayList()
Creates an empty
CopyOnWriteArrayList instance.
|
static <E> CopyOnWriteArrayList |
Lists.newCopyOnWriteArrayList(Iterable
Creates a
CopyOnWriteArrayList instance containing the given elements.
|
static <E> CopyOnWriteArraySet |
Sets.newCopyOnWriteArraySet()
Creates an empty
CopyOnWriteArraySet instance.
|
static <E> CopyOnWriteArraySet |
Sets.newCopyOnWriteArraySet(Iterable
Creates a
CopyOnWriteArraySet instance containing the given elements.
|
static <E> Interner |
Interners.newWeakInterner()
Returns a new thread-safe interner which retains a weak reference to each instance it has interned, and so does not prevent these instances from being garbage-collected.
|
E |
ImmutableSortedSet.pollFirst()
Deprecated.
Unsupported operation.
|
E |
ImmutableSortedSet.pollLast()
Deprecated.
Unsupported operation.
|
ContiguousSet |
ContiguousSet.subSet(C fromElement, boolean fromInclusive, C toElement, boolean toInclusive)
|
ImmutableSortedSet |
ImmutableSortedSet.subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
|
static <K |
Maps.synchronizedNavigableMap(NavigableMap
Returns a synchronized (thread-safe) navigable map backed by the specified navigable map.
|
static <E> NavigableSet |
Sets.synchronizedNavigableSet(NavigableSet
Returns a synchronized (thread-safe) navigable set backed by the specified navigable set.
|
ContiguousSet |
ContiguousSet.tailSet(C fromElement, boolean inclusive)
|
ImmutableSortedSet |
ImmutableSortedSet.tailSet(E fromElement, boolean inclusive)
|
E[] |
FluentIterable.toArray(Class
Returns an array containing all of the elements from this fluent iterable in iteration order.
|
V[][] |
ArrayTable.toArray(Class
Returns a two-dimensional array with the table contents.
|
static <T> T[] |
Iterables.toArray(Iterable
Copies an iterable's elements into an array.
|
static <T> T[] |
Iterators.toArray(Iterator
Copies an iterator's elements into an array.
|
static <K |
Maps.transformEntries(NavigableMap
Returns a view of a navigable map whose values are derived from the original navigable map's entries.
|
static <K |
Maps.transformValues(NavigableMap
Returns a view of a navigable map where each value is transformed by a function.
|
static <K |
Maps.unmodifiableNavigableMap(NavigableMap
Returns an unmodifiable view of the specified navigable map.
|
static <E> NavigableSet |
Sets.unmodifiableNavigableSet(NavigableSet
Returns an unmodifiable view of the specified navigable set.
|
MapMaker |
MapMaker.weakKeys()
Specifies that each key (not value) stored in the map should be wrapped in a
WeakReference (by default, strong references are used).
|
MapMaker |
MapMaker.weakValues()
Specifies that each value (not key) stored in the map should be wrapped in a
WeakReference (by default, strong references are used).
|
| Modifier and Type | Method and Description |
|---|---|
ByteSource |
BaseEncoding.decodingSource(CharSource
Returns a
ByteSource that reads base-encoded bytes from the specified
CharSource.
|
abstract InputStream |
BaseEncoding.decodingStream(Reader
Returns an
InputStream that decodes base-encoded input from the specified
Reader.
|
ByteSink |
BaseEncoding.encodingSink(CharSink
Returns a
ByteSink that writes base-encoded bytes to the specified
CharSink.
|
abstract OutputStream |
BaseEncoding.encodingStream(Writer
Returns an
OutputStream that encodes bytes using this encoding into the specified
Writer.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
IntMath.binomial(int n, int k)
Returns
n choose
k, also known as the binomial coefficient of
n and
k, or
Integer if the result does not fit in an
int.
|
static long |
LongMath.checkedAdd(long a, long b)
Returns the sum of
a and
b, provided it does not overflow.
|
static long |
LongMath.checkedMultiply(long a, long b)
Returns the product of
a and
b, provided it does not overflow.
|
static long |
LongMath.checkedPow(long b, int k)
Returns the
b to the
kth power, provided it does not overflow.
|
static long |
LongMath.checkedSubtract(long a, long b)
Returns the difference of
a and
b, provided it does not overflow.
|
static BigInteger |
BigIntegerMath.divide(BigInteger
Returns the result of dividing
p by
q, rounding using the specified
RoundingMode.
|
static long |
LongMath.divide(long p, long q, RoundingMode
Returns the result of dividing
p by
q, rounding using the specified
RoundingMode.
|
static long |
LongMath.factorial(int n)
Returns
n!, that is, the product of the first
n positive integers,
1 if
n == 0, or
Long if the result does not fit in a
long.
|
static boolean |
DoubleMath.isMathematicalInteger(double x)
Returns
true if
x represents a mathematical integer.
|
static boolean |
DoubleMath.isPowerOfTwo(double x)
Returns
true if
x is exactly equal to
2^k for some finite integer
k.
|
static int |
BigIntegerMath.log10(BigInteger
Returns the base-10 logarithm of
x, rounded according to the specified rounding mode.
|
static int |
IntMath.log10(int x, RoundingMode
Returns the base-10 logarithm of
x, rounded according to the specified rounding mode.
|
static int |
LongMath.log10(long x, RoundingMode
Returns the base-10 logarithm of
x, rounded according to the specified rounding mode.
|
static int |
DoubleMath.log2(double x, RoundingMode
Returns the base 2 logarithm of a double value, rounded with the specified rounding mode to an
int.
|
static double |
DoubleMath.mean(double... values)
Returns the
arithmetic mean of
values.
|
static double |
DoubleMath.mean(Iterable
Returns the
arithmetic mean of
values.
|
static double |
DoubleMath.mean(Iterator
Returns the
arithmetic mean of
values.
|
static int |
LongMath.mod(long x, int m)
Returns
x mod m, a non-negative value less than
m.
|
static long |
LongMath.mod(long x, long m)
Returns
x mod m, a non-negative value less than
m.
|
static int |
IntMath.pow(int b, int k)
Returns
b to the
kth power.
|
static long |
LongMath.pow(long b, int k)
Returns
b to the
kth power.
|
static BigInteger |
DoubleMath.roundToBigInteger(double x, RoundingMode
Returns the
BigInteger value that is equal to
x rounded with the specified rounding mode, if possible.
|
static int |
DoubleMath.roundToInt(double x, RoundingMode
Returns the
int value that is equal to
x rounded with the specified rounding mode, if possible.
|
static long |
DoubleMath.roundToLong(double x, RoundingMode
Returns the
long value that is equal to
x rounded with the specified rounding mode, if possible.
|
static BigInteger |
BigIntegerMath.sqrt(BigInteger
Returns the square root of
x, rounded with the specified rounding mode.
|
static int |
IntMath.sqrt(int x, RoundingMode
Returns the square root of
x, rounded with the specified rounding mode.
|
static long |
LongMath.sqrt(long x, RoundingMode
Returns the square root of
x, rounded with the specified rounding mode.
|
| Modifier and Type | Method and Description |
|---|---|
static short |
Shorts.fromByteArray(byte[] bytes)
Returns the
short value whose big-endian representation is stored in the first 2 bytes of
bytes; equivalent to
ByteBuffer.wrap(bytes).getShort().
|
static int |
Ints.fromByteArray(byte[] bytes)
Returns the
int value whose big-endian representation is stored in the first 4 bytes of
bytes; equivalent to
ByteBuffer.wrap(bytes).getInt().
|
static char |
Chars.fromByteArray(byte[] bytes)
Returns the
char value whose big-endian representation is stored in the first 2 bytes of
bytes; equivalent to
ByteBuffer.wrap(bytes).getChar().
|
static short |
Shorts.fromBytes(byte b1, byte b2)
Returns the
short value whose byte representation is the given 2 bytes, in big-endian order; equivalent to
Shorts.fromByteArray(new byte[] {b1, b2}).
|
static char |
Chars.fromBytes(byte b1, byte b2)
Returns the
char value whose byte representation is the given 2 bytes, in big-endian order; equivalent to
Chars.fromByteArray(new byte[] {b1, b2}).
|
static int |
Ints.fromBytes(byte b1, byte b2, byte b3, byte b4)
Returns the
int value whose byte representation is the given 4 bytes, in big-endian order; equivalent to
Ints.fromByteArray(new byte[] {b1, b2, b3, b4}).
|
UnsignedInteger |
UnsignedInteger.times(UnsignedInteger
Returns the result of multiplying this and
val.
|
static byte[] |
Chars.toByteArray(char value)
Returns a big-endian representation of
value in a 2-element byte array; equivalent to
ByteBuffer.allocate(2).putChar(value).array().
|
static byte[] |
Ints.toByteArray(int value)
Returns a big-endian representation of
value in a 4-element byte array; equivalent to
ByteBuffer.allocate(4).putInt(value).array().
|
static byte[] |
Shorts.toByteArray(short value)
Returns a big-endian representation of
value in a 2-element byte array; equivalent to
ByteBuffer.allocate(2).putShort(value).array().
|
static Double |
Doubles.tryParse(String
Parses the specified string as a double-precision floating point value.
|
static Float |
Floats.tryParse(String
Parses the specified string as a single-precision floating point value.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
MoreExecutors.addDelayedShutdownHook(ExecutorService
Add a shutdown hook to wait for thread completion in the given
service.
|
static void |
Uninterruptibles.awaitUninterruptibly(CountDownLatch
Invokes
latch.
await() uninterruptibly.
|
static boolean |
Uninterruptibles.awaitUninterruptibly(CountDownLatch
Invokes
latch.
await(timeout, unit) uninterruptibly.
|
static <V |
Futures.catching(ListenableFuture
Returns a
Future whose result is taken from the given primary
input or, if the primary input fails with the given
exceptionType, from the result provided by the
fallback.
|
static <V |
Futures.catching(ListenableFuture
Returns a
Future whose result is taken from the given primary
input or, if the primary input fails with the given
exceptionType, from the result provided by the
fallback.
|
static <V |
Futures.catchingAsync(ListenableFuture
Returns a
Future whose result is taken from the given primary
input or, if the primary input fails with the given
exceptionType, from the result provided by the
fallback.
|
static <V |
Futures.catchingAsync(ListenableFuture
Returns a
Future whose result is taken from the given primary
input or, if the primary input fails with the given
exceptionType, from the result provided by the
fallback.
|
static <V |
Futures.get(Future
Deprecated.
Use
Futures. This method will be removed in Guava release 20.0.
|
static <V |
Futures.get(Future
Deprecated.
Use
Futures, noting the change in parameter order. This method will be removed in Guava release 20.0.
|
static <V |
Futures.getChecked(Future
Returns the result of
Future, converting most exceptions to a new instance of the given checked exception type.
|
static <V |
Futures.getChecked(Future
Returns the result of
Future, converting most exceptions to a new instance of the given checked exception type.
|
static ExecutorService |
MoreExecutors.getExitingExecutorService(ThreadPoolExecutor
Converts the given ThreadPoolExecutor into an ExecutorService that exits when the application is complete.
|
static ExecutorService |
MoreExecutors.getExitingExecutorService(ThreadPoolExecutor
Converts the given ThreadPoolExecutor into an ExecutorService that exits when the application is complete.
|
static ScheduledExecutorService |
MoreExecutors.getExitingScheduledExecutorService(ScheduledThreadPoolExecutor
Converts the given ThreadPoolExecutor into a ScheduledExecutorService that exits when the application is complete.
|
static ScheduledExecutorService |
MoreExecutors.getExitingScheduledExecutorService(ScheduledThreadPoolExecutor
Converts the given ScheduledThreadPoolExecutor into a ScheduledExecutorService that exits when the application is complete.
|
static <V> V |
Futures.getUnchecked(Future
Returns the result of calling
Future uninterruptibly on a task known not to throw a checked exception.
|
static <V> V |
Uninterruptibles.getUninterruptibly(Future
Invokes
future.
get(timeout, unit) uninterruptibly.
|
static <V> ListenableFuture |
Futures.immediateCancelledFuture()
Creates a
ListenableFuture which is cancelled immediately upon construction, so that
isCancelled() always returns
true.
|
static <V |
Futures.immediateCheckedFuture(V value)
Returns a
CheckedFuture which has its value set immediately upon construction.
|
static <V |
Futures.immediateFailedCheckedFuture(X exception)
Returns a
CheckedFuture which has an exception set immediately upon construction.
|
static <T> ImmutableList |
Futures.inCompletionOrder(Iterable
Returns a list of delegate futures that correspond to the futures received in the order that they complete.
|
static void |
Uninterruptibles.joinUninterruptibly(Thread
Invokes
toJoin.
join() uninterruptibly.
|
static void |
Uninterruptibles.joinUninterruptibly(Thread
Invokes
unit.
timedJoin(toJoin, timeout) uninterruptibly.
|
static <I |
Futures.lazyTransform(Future
Like
Futures except that the transformation
function is invoked on each call to
get() on the returned future.
|
static ListeningExecutorService |
MoreExecutors.listeningDecorator(ExecutorService
Creates an
ExecutorService whose
submit and
invokeAll methods submit
ListenableFutureTask instances to the given delegate executor.
|
static ListeningScheduledExecutorService |
MoreExecutors.listeningDecorator(ScheduledExecutorService
Creates a
ScheduledExecutorService whose
submit and
invokeAll methods submit
ListenableFutureTask instances to the given delegate executor.
|
static <V |
Futures.makeChecked(ListenableFuture
Creates a
CheckedFuture out of a normal
ListenableFuture and a
Function that maps from
Exception instances into the appropriate checked type.
|
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 <V> ListenableFuture |
Futures.nonCancellationPropagating(ListenableFuture
Creates a new
ListenableFuture whose result is set from the supplied future when it completes.
|
static ThreadFactory |
MoreExecutors.platformThreadFactory()
Returns a default thread factory used to create new threads.
|
static <E> void |
Uninterruptibles.putUninterruptibly(BlockingQueue
Invokes
queue.
put(element) uninterruptibly.
|
static ListeningExecutorService |
MoreExecutors.sameThreadExecutor()
Deprecated.
Use
MoreExecutors if you only require an Executor and MoreExecutors if you need a ListeningExecutorService. This method will be removed in August 2016.
|
static boolean |
MoreExecutors.shutdownAndAwaitTermination(ExecutorService
Shuts down the given executor gradually, first disabling new submissions and later cancelling existing tasks.
|
static void |
Uninterruptibles.sleepUninterruptibly(long sleepFor, TimeUnit
Invokes
unit.
sleep(sleepFor) uninterruptibly.
|
static <E> E |
Uninterruptibles.takeUninterruptibly(BlockingQueue
Invokes
queue.
take() uninterruptibly.
|
static boolean |
Uninterruptibles.tryAcquireUninterruptibly(Semaphore
Invokes
semaphore.
tryAcquire(permits, timeout, unit) uninterruptibly.
|
static boolean |
Uninterruptibles.tryAcquireUninterruptibly(Semaphore
Invokes
semaphore.
tryAcquire(1, timeout, unit) uninterruptibly.
|
static <V> ListenableFuture |
Futures.withTimeout(ListenableFuture
Returns a future that delegates to another but will finish early (via a
TimeoutException wrapped in an
ExecutionException) if the specified duration expires.
|