Package org.osgi.util.function
Interface Function<T,R>
- Type Parameters:
T
- The type of the function input.R
- The type of the function output.
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A function that accepts a single argument and produces a result.
This is a functional interface and can be used as the assignment target for a lambda expression or method reference.
- "ThreadSafe"
-
Method Summary
Modifier and TypeMethodDescriptionCompose the specifiedFunction
to be called on the value returned by thisFunction
.Applies this function to the specified argument.static <T,
R> Function<T, R> asFunction
(Function<T, R> wrapped) Returns aFunction
which wraps the specifiedjava.util.function.Function
.static <T,
R> Function<T, R> asJavaFunction
(Function<T, R> wrapped) Returns ajava.util.function.Function
which wraps the specifiedFunction
and throws any thrown exceptions.static <T,
R> Function<T, R> asJavaFunctionOrElse
(Function<T, R> wrapped, R orElse) Returns ajava.util.function.Function
which wraps the specifiedFunction
and the specified value.static <T,
R> Function<T, R> asJavaFunctionOrElseGet
(Function<T, R> wrapped, Supplier<? extends R> orElseGet) Returns ajava.util.function.Function
which wraps the specifiedFunction
and the specifiedjava.util.function.Supplier
.Compose the specifiedFunction
to be called to supply a value to be consumed by thisFunction
.
-
Method Details
-
apply
Applies this function to the specified argument.- Parameters:
t
- The input to this function.- Returns:
- The output of this function.
- Throws:
Exception
- An exception thrown by the method.
-
andThen
Compose the specifiedFunction
to be called on the value returned by thisFunction
.- Type Parameters:
S
- The type of the value supplied by the specifiedFunction
.- Parameters:
after
- TheFunction
to be called on the value returned by thisFunction
. Must not benull
.- Returns:
- A
Function
composed of thisFunction
and the specifiedFunction
.
-
compose
Compose the specifiedFunction
to be called to supply a value to be consumed by thisFunction
.- Type Parameters:
S
- The type of the value consumed the specifiedFunction
.- Parameters:
before
- TheFunction
to be called to supply a value to be consumed by thisFunction
. Must not benull
.- Returns:
- A
Function
composed of thisFunction
and the specifiedFunction
.
-
asJavaFunction
Returns ajava.util.function.Function
which wraps the specifiedFunction
and throws any thrown exceptions.The returned
java.util.function.Function
will throw any exception thrown by the wrappedFunction
.- Type Parameters:
T
- The type of the function input.R
- The type of the function output.- Parameters:
wrapped
- TheFunction
to wrap. Must not benull
.- Returns:
- A
java.util.function.Function
which wraps the specifiedFunction
.
-
asJavaFunctionOrElse
Returns ajava.util.function.Function
which wraps the specifiedFunction
and the specified value.If the the specified
Function
throws anException
, the the specified value is returned.- Type Parameters:
T
- The type of the function input.R
- The type of the function output.- Parameters:
wrapped
- TheFunction
to wrap. Must not benull
.orElse
- The value to return if the specifiedFunction
throws anException
.- Returns:
- A
java.util.function.Function
which wraps the specifiedFunction
and the specified value.
-
asJavaFunctionOrElseGet
static <T,R> Function<T,R> asJavaFunctionOrElseGet(Function<T, R> wrapped, Supplier<? extends R> orElseGet) Returns ajava.util.function.Function
which wraps the specifiedFunction
and the specifiedjava.util.function.Supplier
.If the the specified
Function
throws anException
, the value returned by the specifiedjava.util.function.Supplier
is returned.- Type Parameters:
T
- The type of the function input.R
- The type of the function output.- Parameters:
wrapped
- TheFunction
to wrap. Must not benull
.orElseGet
- Thejava.util.function.Supplier
to call for a return value if the specifiedFunction
throws anException
.- Returns:
- A
java.util.function.Function
which wraps the specifiedFunction
and the specifiedjava.util.function.Supplier
.
-
asFunction
Returns aFunction
which wraps the specifiedjava.util.function.Function
.- Type Parameters:
T
- The type of the function input.R
- The type of the function output.- Parameters:
wrapped
- Thejava.util.function.Function
to wrap. Must not benull
.- Returns:
- A
Function
which wraps the specifiedjava.util.function.Function
.
-