T
- The type of the function input.R
- The type of the function output.@ConsumerType @FunctionalInterface public interface Function<T,R>
This is a functional interface and can be used as the assignment target for a lambda expression or method reference.
Modifier and Type | Method and Description |
---|---|
default <S> Function<T,S> |
andThen(Function<? super R,? extends S> after)
Compose the specified
Function to be called on the value returned
by this Function . |
R |
apply(T t)
Applies this function to the specified argument.
|
static <T,R> Function<T,R> |
asFunction(Function<T,R> wrapped)
Returns a
Function which wraps the specified
java.util.function.Function . |
static <T,R> Function<T,R> |
asJavaFunction(Function<T,R> wrapped)
Returns a
java.util.function.Function which wraps the specified
Function and throws any thrown exceptions. |
static <T,R> Function<T,R> |
asJavaFunctionOrElse(Function<T,R> wrapped,
R orElse)
Returns a
java.util.function.Function which wraps the specified
Function and the specified value. |
static <T,R> Function<T,R> |
asJavaFunctionOrElseGet(Function<T,R> wrapped,
Supplier<? extends R> orElseGet)
Returns a
java.util.function.Function which wraps the specified
Function and the specified java.util.function.Supplier . |
default <S> Function<S,R> |
compose(Function<? super S,? extends T> before)
Compose the specified
Function to be called to supply a value to
be consumed by this Function . |
R apply(T t) throws Exception
t
- The input to this function.Exception
- An exception thrown by the method.default <S> Function<T,S> andThen(Function<? super R,? extends S> after)
Function
to be called on the value returned
by this Function
.S
- The type of the value supplied by the specified
Function
.after
- The Function
to be called on the value returned by
this Function
. Must not be null
.Function
composed of this Function
and the
specified Function
.default <S> Function<S,R> compose(Function<? super S,? extends T> before)
Function
to be called to supply a value to
be consumed by this Function
.S
- The type of the value consumed the specified Function
.before
- The Function
to be called to supply a value to be
consumed by this Function
. Must not be null
.Function
composed of this Function
and the
specified Function
.static <T,R> Function<T,R> asJavaFunction(Function<T,R> wrapped)
java.util.function.Function
which wraps the specified
Function
and throws any thrown exceptions.
The returned java.util.function.Function
will throw any exception
thrown by the wrapped Function
.
T
- The type of the function input.R
- The type of the function output.wrapped
- The Function
to wrap. Must not be null
.java.util.function.Function
which wraps the specified
Function
.static <T,R> Function<T,R> asJavaFunctionOrElse(Function<T,R> wrapped, R orElse)
java.util.function.Function
which wraps the specified
Function
and the specified value.
If the the specified Function
throws an Exception
, the
the specified value is returned.
T
- The type of the function input.R
- The type of the function output.wrapped
- The Function
to wrap. Must not be null
.orElse
- The value to return if the specified Function
throws an Exception
.java.util.function.Function
which wraps the specified
Function
and the specified value.static <T,R> Function<T,R> asJavaFunctionOrElseGet(Function<T,R> wrapped, Supplier<? extends R> orElseGet)
java.util.function.Function
which wraps the specified
Function
and the specified java.util.function.Supplier
.
If the the specified Function
throws an Exception
, the
value returned by the specified java.util.function.Supplier
is
returned.
T
- The type of the function input.R
- The type of the function output.wrapped
- The Function
to wrap. Must not be null
.orElseGet
- The java.util.function.Supplier
to call for a
return value if the specified Function
throws an
Exception
.java.util.function.Function
which wraps the specified
Function
and the specified
java.util.function.Supplier
.static <T,R> Function<T,R> asFunction(Function<T,R> wrapped)
Function
which wraps the specified
java.util.function.Function
.T
- The type of the function input.R
- The type of the function output.wrapped
- The java.util.function.Function
to wrap. Must not
be null
.Function
which wraps the specified
java.util.function.Function
.Copyright © Contributors to the Eclipse Foundation Licensed under the Eclipse Foundation Specification License – v1.0