Uses of Interface
com.google.common.base.Function
-
Packages that use Function 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.escape Interfaces, utilities, and simple implementations of escapers and encoders.com.google.common.util.concurrent Concurrency utilities. -
-
Uses of Function in com.google.common.base
Classes in com.google.common.base that implement Function Modifier and Type Class Description class
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.Methods in com.google.common.base that return Function Modifier and Type Method Description static <A extends @Nullable java.lang.Object,B extends @Nullable java.lang.Object,C extends @Nullable java.lang.Object>
Function<A,C>Functions. compose(Function<B,C> g, Function<A,? extends B> f)
Returns the composition of two functions.static <E extends @Nullable java.lang.Object>
Function<@Nullable java.lang.Object,E>Functions. constant(E value)
Returns a function that ignores its input and always returnsvalue
.static <K extends @Nullable java.lang.Object,V extends @Nullable java.lang.Object>
Function<K,V>Functions. forMap(java.util.Map<K,? extends V> map, V defaultValue)
Returns a function which performs a map lookup with a default value.static <K extends @Nullable java.lang.Object,V extends @Nullable java.lang.Object>
Function<K,V>Functions. forMap(java.util.Map<K,V> map)
Returns a function which performs a map lookup.static <T extends @Nullable java.lang.Object>
Function<T,java.lang.Boolean>Functions. forPredicate(Predicate<T> predicate)
Creates a function that returns the same boolean output as the given predicate for all inputs.static <F extends @Nullable java.lang.Object,T extends @Nullable java.lang.Object>
Function<F,T>Functions. forSupplier(Supplier<T> supplier)
Returns a function that ignores its input and returns the result ofsupplier.get()
.static <E extends @Nullable java.lang.Object>
Function<E,E>Functions. identity()
Returns the identity function.static <T extends @Nullable java.lang.Object>
Function<Supplier<T>,T>Suppliers. supplierFunction()
Returns a function that accepts a supplier and returns the result of invokingSupplier.get()
on that supplier.static Function<java.lang.Object,java.lang.String>
Functions. toStringFunction()
A function equivalent to the method referenceObject::toString
, for users not yet using Java 8.Methods in com.google.common.base with parameters of type Function Modifier and Type Method Description static <A extends @Nullable java.lang.Object,B extends @Nullable java.lang.Object,C extends @Nullable java.lang.Object>
Function<A,C>Functions. compose(Function<B,C> g, Function<A,? extends B> f)
Returns the composition of two functions.static <A extends @Nullable java.lang.Object,B extends @Nullable java.lang.Object>
Predicate<A>Predicates. compose(Predicate<B> predicate, Function<A,? extends B> function)
Returns the composition of a function and a predicate.static <F extends @Nullable java.lang.Object,T extends @Nullable java.lang.Object>
Supplier<T>Suppliers. compose(Function<? super F,T> function, Supplier<F> supplier)
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.<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>
Optional. transform(Function<? super T,V> function)
If the instance is present, it is transformed with the givenFunction
; otherwise,Optional.absent()
is returned. -
Uses of Function in com.google.common.cache
Subinterfaces of Function in com.google.common.cache Modifier and Type Interface Description interface
LoadingCache<K,V>
A semi-persistent mapping from keys to values.Classes in com.google.common.cache that implement Function Modifier and Type Class Description class
AbstractLoadingCache<K,V>
This class provides a skeletal implementation of theCache
interface to minimize the effort required to implement this interface.class
ForwardingLoadingCache<K,V>
A cache which forwards all its method calls to another cache.static class
ForwardingLoadingCache.SimpleForwardingLoadingCache<K,V>
A simplified version ofForwardingLoadingCache
where subclasses can pass in an already constructedLoadingCache
as the delegate.Methods in com.google.common.cache with parameters of type Function Modifier and Type Method Description static <K,V>
CacheLoader<K,V>CacheLoader. from(Function<K,V> function)
Returns a cache loader that usesfunction
to load keys, without supporting either reloading or bulk loading. -
Uses of Function in com.google.common.collect
Methods in com.google.common.collect that return Function Modifier and Type Method Description static <E> Function<E,E>
Interners. asFunction(Interner<E> interner)
Returns a function that delegates to theInterner.intern(E)
method of the given interner.Methods in com.google.common.collect with parameters of type Function Modifier and Type Method Description static <K extends @Nullable java.lang.Object,V extends @Nullable java.lang.Object>
java.util.NavigableMap<K,V>Maps. asMap(java.util.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.static <K extends @Nullable java.lang.Object,V extends @Nullable java.lang.Object>
java.util.Map<K,V>Maps. asMap(java.util.Set<K> set, Function<? super K,V> function)
Returns a liveMap
view whose keys are the contents ofset
and whose values are computed on demand usingfunction
.static <K extends @Nullable java.lang.Object,V extends @Nullable java.lang.Object>
java.util.SortedMap<K,V>Maps. asMap(java.util.SortedSet<K> set, Function<? super K,V> function)
Returns a view of the sorted set as a map, mapping keys from the set according to the specified function.<K> ImmutableListMultimap<K,@NonNull E>
FluentIterable. index(Function<? super E,K> keyFunction)
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>Multimaps. index(java.lang.Iterable<V> values, Function<? super V,K> keyFunction)
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>Multimaps. index(java.util.Iterator<V> values, Function<? super V,K> keyFunction)
Creates an indexImmutableListMultimap
that contains the results of applying a specified function to each item in anIterator
of values.<F extends @Nullable java.lang.Object>
Ordering<F>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
.<V> ImmutableMap<@NonNull E,V>
FluentIterable. toMap(Function<? super E,V> valueFunction)
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>Maps. toMap(java.lang.Iterable<K> keys, Function<? super K,V> valueFunction)
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>Maps. toMap(java.util.Iterator<K> keys, Function<? super K,V> valueFunction)
Returns an immutable map whose keys are the distinct elements ofkeys
and whose value for each key was computed byvalueFunction
.static <F extends @Nullable java.lang.Object,T extends @Nullable java.lang.Object>
java.util.Collection<T>Collections2. transform(java.util.Collection<F> fromCollection, Function<? super F,T> function)
Returns a collection that appliesfunction
to each element offromCollection
.<T extends @Nullable java.lang.Object>
FluentIterable<T>FluentIterable. transform(Function<? super E,T> function)
Returns a fluent iterable that appliesfunction
to each element of this fluent iterable.static <F extends @Nullable java.lang.Object,T extends @Nullable java.lang.Object>
java.lang.Iterable<T>Iterables. transform(java.lang.Iterable<F> fromIterable, Function<? super F,? extends T> function)
Returns a view containing the result of applyingfunction
to each element offromIterable
.static <F extends @Nullable java.lang.Object,T extends @Nullable java.lang.Object>
java.util.Iterator<T>Iterators. transform(java.util.Iterator<F> fromIterator, Function<? super F,? extends T> function)
Returns a view containing the result of applyingfunction
to each element offromIterator
.static <F extends @Nullable java.lang.Object,T extends @Nullable java.lang.Object>
java.util.List<T>Lists. transform(java.util.List<F> fromList, Function<? super F,? extends T> function)
Returns a list that appliesfunction
to each element offromList
.<T extends @Nullable java.lang.Object>
FluentIterable<T>FluentIterable. transformAndConcat(Function<? super E,? extends java.lang.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 java.lang.Object,V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.Object>
java.util.Map<K,V2>Maps. transformValues(java.util.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 java.lang.Object,V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.Object>
java.util.NavigableMap<K,V2>Maps. transformValues(java.util.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 java.lang.Object,V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.Object>
java.util.SortedMap<K,V2>Maps. transformValues(java.util.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 java.lang.Object,V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.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 java.lang.Object,V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.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 java.lang.Object,C extends @Nullable java.lang.Object,V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.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.<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(java.lang.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(java.util.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>
TreeTraverser. using(Function<T,? extends java.lang.Iterable<T>> nodeToChildrenFunction)
Deprecated. -
Uses of Function in com.google.common.escape
Methods in com.google.common.escape that return Function Modifier and Type Method Description Function<java.lang.String,java.lang.String>
Escaper. asFunction()
Returns aFunction
that invokesEscaper.escape(String)
on this escaper. -
Uses of Function in com.google.common.util.concurrent
Methods in com.google.common.util.concurrent with parameters of type Function Modifier and Type Method Description <X extends java.lang.Throwable>
FluentFuture<V>FluentFuture. catching(java.lang.Class<X> exceptionType, Function<? super X,? extends V> fallback, java.util.concurrent.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 java.lang.Object,X extends java.lang.Throwable>
ListenableFuture<V>Futures. catching(ListenableFuture<? extends V> input, java.lang.Class<X> exceptionType, Function<? super X,? extends V> fallback, java.util.concurrent.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
.static <I extends @Nullable java.lang.Object,O extends @Nullable java.lang.Object>
java.util.concurrent.Future<O>Futures. lazyTransform(java.util.concurrent.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.<T extends @Nullable java.lang.Object>
FluentFuture<T>FluentFuture. transform(Function<? super V,T> function, java.util.concurrent.Executor executor)
Returns a newFuture
whose result is derived from the result of thisFuture
.static <I extends @Nullable java.lang.Object,O extends @Nullable java.lang.Object>
ListenableFuture<O>Futures. transform(ListenableFuture<I> input, Function<? super I,? extends O> function, java.util.concurrent.Executor executor)
Returns a newFuture
whose result is derived from the result of the givenFuture
.
-