Interface Function<T,R>
- Type Parameters:
T- the function parameter typeR- the function return type
- All Superinterfaces:
Function<T,R>
- All Known Subinterfaces:
UnaryOperator<T>
- All Known Implementing Classes:
CacheFactory, SessionAttributeActivationNotifierFactory
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault <V1,V2> BiFunction <V1, V2, R> compose(BiFunction<V1, V2, T> mapper) Composes a binary function that invokes this function using result of the specified binary function.static <T,R> Function <T, R> empty()Returns a function that returns its parameter.Returns aMap.Entryfunction from the specified key and value functions.handle(BiFunction<T, RuntimeException, R> handler) Returns a new function that delegates to this function using the specified exception handler.static <T extends R, R>
Function<T, R> identity()Returns a function that returns its parameter.static <T,R> Function <T, R> Returns a function that accepts its parameter via the specified consumer and returns the value returned by the specified supplier.static <T,R> Function <T, R> of(R result) Returns a function that always returns the specified value, ignoring its parameter.optional()Returns an optional function that applies this function to an optional value.Returns a function that applies this function if its parameter matches the specified predicate, or returns the value provided by the specified supplier otherwise.withDefault(Predicate<T> predicate, Supplier<T> defaultValue) Returns a function that applies this function to the value returned by the specified provider if its value does not match the specified predicate.withMonitor(Function<T, M> monitorFunction) Returns a new function that applies this function while holding the monitor returned by the specified function.
-
Field Details
-
IDENTITY
An identity function that always returns its parameter -
NULL
A function that always returns null.
-
-
Method Details
-
compose
-
compose
Composes a binary function that invokes this function using result of the specified binary function.- Type Parameters:
V1- the former parameter typeV2- the latter parameter type- Parameters:
mapper- a mapping function- Returns:
- a binary function that invokes this function using result of the specified binary function.
-
andThen
-
withDefault
Returns a function that applies this function to the value returned by the specified provider if its value does not match the specified predicate.- Parameters:
predicate- a predicate used to determine the parameter of this functiondefaultValue- a provider of the default parameter value- Returns:
- a function that applies this function to the value returned by the specified provider if its value does not match the specified predicate.
-
orDefault
Returns a function that applies this function if its parameter matches the specified predicate, or returns the value provided by the specified supplier otherwise.- Parameters:
predicate- a predicate used to determine the parameter of this functiondefaultResult- a provider of the default parameter value- Returns:
- a function that applies this function if its parameter matches the specified predicate, or returns the value provided by the specified supplier otherwise.
-
handle
Returns a new function that delegates to this function using the specified exception handler.- Parameters:
handler- an exception handler- Returns:
- a new function that delegates to this function using the specified exception handler.
-
optional
-
withMonitor
Returns a new function that applies this function while holding the monitor returned by the specified function.- Type Parameters:
M- a function returning an object monitor- Parameters:
monitorFunction- a function returning an object monitor.- Returns:
- a new function that applies this function while holding the monitor returned by the specified function.
-
identity
Returns a function that returns its parameter.- Type Parameters:
T- the function parameter typeR- the function return type- Returns:
- an identity function
-
empty
Returns a function that returns its parameter.- Type Parameters:
T- the function parameter typeR- the function return type- Returns:
- an identity function
-
of
Returns a function that always returns the specified value, ignoring its parameter.- Type Parameters:
T- the function parameter typeR- the function return type- Parameters:
result- the function result- Returns:
- a function that always returns the specified value, ignoring its parameter.
-
of
Returns a function that accepts its parameter via the specified consumer and returns the value returned by the specified supplier.- Type Parameters:
T- the function parameter typeR- the function return type- Parameters:
consumer- the consumer of the function parametersupplier- the supplier of the function result- Returns:
- a function that accepts its parameter via the specified consumer and returns the value returned by the specified supplier.
-
entry
static <K,V, Function<Map.Entry<K,KR, VR> V>, Map.Entry<KR, entryVR>> (Function<K, KR> keyFunction, Function<V, VR> valueFunction) Returns aMap.Entryfunction from the specified key and value functions.- Type Parameters:
K- the entry key typeV- the entry value typeKR- the mapped entry key typeVR- the mapped entry value type- Parameters:
keyFunction- an entry key functionvalueFunction- an entry value function- Returns:
- a
Map.Entryfunction from the specified key and value functions.
-