Package com.google.common.base
Class Functions
java.lang.Object
com.google.common.base.Functions
Deprecated.
The Google Guava Core Libraries are deprecated and will not be part of the AEM SDK after April 2023
Static utility methods pertaining to
Function
instances.
All methods return serializable functions as long as they're given serializable parameters.
See the Guava User Guide article on the use of
Function
.
- Since:
- 2.0 (imported from Google Collections Library)
-
Method Summary
Modifier and TypeMethodDescriptionstatic <A,
B, C> Function <A, C> Deprecated.Returns the composition of two functions.constant
(E value) Deprecated.Creates a function that returnsvalue
for any input.static <K,
V> Function <K, V> Deprecated.Returns a function which performs a map lookup with a default value.static <K,
V> Function <K, V> Deprecated.Returns a function which performs a map lookup.forPredicate
(Predicate<T> predicate) Deprecated.Creates a function that returns the same boolean output as the given predicate for all inputs.forSupplier
(Supplier<T> supplier) Deprecated.Returns a function that always returns the result of invokingSupplier.get()
onsupplier
, regardless of its input.static <E> Function
<E, E> identity()
Deprecated.Returns the identity function.Deprecated.Returns a function that callstoString()
on its argument.
-
Method Details
-
toStringFunction
Deprecated.Returns a function that callstoString()
on its argument. The function does not accept nulls; it will throw aNullPointerException
when applied tonull
.Warning: The returned function may not be consistent with equals (as documented at
Function.apply(F)
). For example, this function yields different results for the two equal instancesImmutableSet.of(1, 2)
andImmutableSet.of(2, 1)
. -
identity
Deprecated.Returns the identity function. -
forMap
Deprecated.Returns a function which performs a map lookup. The returned function throws anIllegalArgumentException
if given a key that does not exist in the map. -
forMap
Deprecated.Returns a function which performs a map lookup with a default value. The function created by this method returnsdefaultValue
for all inputs that do not belong to the map's key set.- Parameters:
map
- source map that determines the function behaviordefaultValue
- the value to return for inputs that aren't map keys- Returns:
- function that returns
map.get(a)
whena
is a key, ordefaultValue
otherwise
-
compose
Deprecated.Returns the composition of two functions. Forf: A->B
andg: B->C
, composition is defined as the function h such thath(a) == g(f(a))
for eacha
.- Parameters:
g
- the second function to applyf
- the first function to apply- Returns:
- the composition of
f
andg
- See Also:
-
forPredicate
Deprecated.Creates a function that returns the same boolean output as the given predicate for all inputs.The returned function is consistent with equals (as documented at
Function.apply(F)
) if and only ifpredicate
is itself consistent with equals. -
constant
Deprecated.Creates a function that returnsvalue
for any input.- Parameters:
value
- the constant value for the function to return- Returns:
- a function that always returns
value
-
forSupplier
Deprecated.Returns a function that always returns the result of invokingSupplier.get()
onsupplier
, regardless of its input.- Since:
- 10.0
-