Uses of Interface
com.google.common.base.Function
Package
Description
Basic utility libraries and interfaces.
Discouraged (in favor of Caffeine) caching utilities.
Collection interfaces and implementations, and other utilities for collections.
Interfaces, utilities, and simple implementations of escapers and encoders.
Concurrency utilities.
-
Uses of Function in com.google.common.base
Modifier and TypeClassDescriptionclass
Converter<A,
B> A function fromA
toB
with an associated reverse function fromB
toA
; used for converting back and forth between different representations of the same information.Modifier and TypeMethodDescriptionstatic <A extends @Nullable Object,
B extends @Nullable Object, C extends @Nullable Object>
Function<A, C> Returns the composition of two functions.Functions.constant
(E value) Returns a function that ignores its input and always returnsvalue
.Returns a function which performs a map lookup with a default value.Returns a function which performs a map lookup.Functions.forPredicate
(Predicate<T> predicate) Creates a function that returns the same boolean output as the given predicate for all inputs.Functions.forSupplier
(Supplier<T> supplier) Returns a function that ignores its input and returns the result ofsupplier.get()
.Functions.identity()
Returns the identity function.Suppliers.supplierFunction()
Returns a function that accepts a supplier and returns the result of invokingSupplier.get()
on that supplier.Functions.toStringFunction()
A function equivalent to the method referenceObject::toString
, for users not yet using Java 8.Modifier and TypeMethodDescriptionstatic <A extends @Nullable Object,
B extends @Nullable Object, C extends @Nullable Object>
Function<A, C> Returns the composition of two functions.Returns the composition of a function and a predicate.Returns a new supplier which is the composition of the provided function and supplier.static <A,
B> Converter <A, B> Converter.from
(Function<? super A, ? extends B> forwardFunction, Function<? super B, ? extends A> backwardFunction) Returns a converter based on separate forward and backward functions.final <F> Equivalence
<F> Equivalence.onResultOf
(Function<? super F, ? extends @Nullable T> function) Returns a new equivalence relation forF
which evaluates equivalence by first applyingfunction
to the argument, then evaluating usingthis
.abstract <V> Optional
<V> If the instance is present, it is transformed with the givenFunction
; otherwise,Optional.absent()
is returned. -
Uses of Function in com.google.common.cache
Modifier and TypeInterfaceDescriptioninterface
LoadingCache<K,
V> A semi-persistent mapping from keys to values.Modifier and TypeClassDescriptionclass
AbstractLoadingCache<K,
V> This class provides a skeletal implementation of theCache
interface to minimize the effort required to implement this interface.class
A cache which forwards all its method calls to another cache.static class
A simplified version ofForwardingLoadingCache
where subclasses can pass in an already constructedLoadingCache
as the delegate.Modifier and TypeMethodDescriptionstatic <K,
V> CacheLoader <K, V> Returns a cache loader that usesfunction
to load keys, without supporting either reloading or bulk loading. -
Uses of Function in com.google.common.collect
Modifier and TypeMethodDescriptionstatic <E> Function
<E, E> Interners.asFunction
(Interner<E> interner) Returns a function that delegates to theInterner.intern(E)
method of the given interner.Modifier and TypeMethodDescriptionstatic <K extends @Nullable Object,
V extends @Nullable Object>
NavigableMap<K, V> Maps.asMap
(NavigableSet<K> set, Function<? super K, V> function) Returns a view of the navigable set as a map, mapping keys from the set according to the specified function.Returns a liveMap
view whose keys are the contents ofset
and whose values are computed on demand usingfunction
.Returns a view of the sorted set as a map, mapping keys from the set according to the specified function.final <K> ImmutableListMultimap
<K, @NonNull E> Creates an indexImmutableListMultimap
that contains the results of applying a specified function to each item in thisFluentIterable
of values.static <K,
V> ImmutableListMultimap <K, V> Creates an indexImmutableListMultimap
that contains the results of applying a specified function to each item in anIterable
of values.static <K,
V> ImmutableListMultimap <K, V> Creates an indexImmutableListMultimap
that contains the results of applying a specified function to each item in anIterator
of values.Ordering.onResultOf
(Function<F, ? extends T> function) Returns a new ordering onF
which orders elements by first applying a function to them, then comparing those results usingthis
.final <V> ImmutableMap
<@NonNull E, V> Returns an immutable map whose keys are the distinct elements of thisFluentIterable
and whose value for each key was computed byvalueFunction
.static <K,
V> ImmutableMap <K, V> Returns an immutable map whose keys are the distinct elements ofkeys
and whose value for each key was computed byvalueFunction
.static <K,
V> ImmutableMap <K, V> Returns an immutable map whose keys are the distinct elements ofkeys
and whose value for each key was computed byvalueFunction
.static <F extends @Nullable Object,
T extends @Nullable Object>
Collection<T> Collections2.transform
(Collection<F> fromCollection, Function<? super F, T> function) Returns a collection that appliesfunction
to each element offromCollection
.final <T extends @Nullable Object>
FluentIterable<T> Returns a fluent iterable that appliesfunction
to each element of this fluent iterable.Returns a view containing the result of applyingfunction
to each element offromIterable
.Returns a view containing the result of applyingfunction
to each element offromIterator
.Returns a list that appliesfunction
to each element offromList
.<T extends @Nullable Object>
FluentIterable<T> FluentIterable.transformAndConcat
(Function<? super E, ? extends Iterable<? extends T>> function) Appliesfunction
to each element of this fluent iterable and returns a fluent iterable with the concatenated combination of results.static <K extends @Nullable Object,
V1 extends @Nullable Object, V2 extends @Nullable Object>
Map<K, V2> Maps.transformValues
(Map<K, V1> fromMap, Function<? super V1, V2> function) Returns a view of a map where each value is transformed by a function.static <K extends @Nullable Object,
V1 extends @Nullable Object, V2 extends @Nullable Object>
NavigableMap<K, V2> Maps.transformValues
(NavigableMap<K, V1> fromMap, Function<? super V1, V2> function) Returns a view of a navigable map where each value is transformed by a function.static <K extends @Nullable Object,
V1 extends @Nullable Object, V2 extends @Nullable Object>
SortedMap<K, V2> Maps.transformValues
(SortedMap<K, V1> fromMap, Function<? super V1, V2> function) Returns a view of a sorted map where each value is transformed by a function.static <K extends @Nullable Object,
V1 extends @Nullable Object, V2 extends @Nullable Object>
ListMultimap<K, V2> Multimaps.transformValues
(ListMultimap<K, V1> fromMultimap, Function<? super V1, V2> function) Returns a view of aListMultimap
where each value is transformed by a function.static <K extends @Nullable Object,
V1 extends @Nullable Object, V2 extends @Nullable Object>
Multimap<K, V2> Multimaps.transformValues
(Multimap<K, V1> fromMultimap, Function<? super V1, V2> function) Returns a view of a multimap where each value is transformed by a function.static <R extends @Nullable Object,
C extends @Nullable Object, V1 extends @Nullable Object, V2 extends @Nullable Object>
Table<R, C, V2> Tables.transformValues
(Table<R, C, V1> fromTable, Function<? super V1, V2> function) Returns a view of a table where each value is transformed by a function.final <K> ImmutableMap
<K, @NonNull E> FluentIterable.uniqueIndex
(Function<? super E, K> keyFunction) Returns a map with the contents of thisFluentIterable
as itsvalues
, indexed by keys derived from those values.static <K,
V> ImmutableMap <K, V> Maps.uniqueIndex
(Iterable<V> values, Function<? super V, K> keyFunction) Returns a map with the givenvalues
, indexed by keys derived from those values.static <K,
V> ImmutableMap <K, V> Maps.uniqueIndex
(Iterator<V> values, Function<? super V, K> keyFunction) Returns a map with the givenvalues
, indexed by keys derived from those values.static <T> TreeTraverser
<T> Deprecated. -
Uses of Function in com.google.common.escape
Modifier and TypeMethodDescriptionEscaper.asFunction()
Returns aFunction
that invokesEscaper.escape(String)
on this escaper. -
Uses of Function in com.google.common.util.concurrent
Modifier and TypeMethodDescriptionfinal <X extends Throwable>
FluentFuture<V> FluentFuture.catching
(Class<X> exceptionType, Function<? super X, ? extends V> fallback, Executor executor) Returns aFuture
whose result is taken from thisFuture
or, if thisFuture
fails with the givenexceptionType
, from the result provided by thefallback
.static <V extends @Nullable Object,
X extends Throwable>
ListenableFuture<V> Futures.catching
(ListenableFuture<? extends V> input, Class<X> exceptionType, Function<? super X, ? extends V> fallback, Executor executor) Returns aFuture
whose result is taken from the given primaryinput
or, if the primary input fails with the givenexceptionType
, from the result provided by thefallback
.Futures.lazyTransform
(Future<I> input, Function<? super I, ? extends O> function) LikeFutures.transform(ListenableFuture, Function, Executor)
except that the transformationfunction
is invoked on each call toget()
on the returned future.final <T extends @Nullable Object>
FluentFuture<T> Returns a newFuture
whose result is derived from the result of thisFuture
.static <I extends @Nullable Object,
O extends @Nullable Object>
ListenableFuture<O> Futures.transform
(ListenableFuture<I> input, Function<? super I, ? extends O> function, Executor executor) Returns a newFuture
whose result is derived from the result of the givenFuture
.
Traverser.forTree(com.google.common.graph.SuccessorsFunction<N>)
instead.