Package org.osgi.util.function
Interface Consumer<T>
- Type Parameters:
T
- The type of the function input.
- 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 no result.
This is a functional interface and can be used as the assignment target for a lambda expression or method reference.
- Since:
- 1.1
- "ThreadSafe"
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Applies this function to the specified argument.Compose the specifiedConsumer
to be called after thisConsumer
.static <T> Consumer<T>
asConsumer
(Consumer<T> wrapped) Returns aConsumer
which wraps ajava.util.function.Consumer
.static <T> Consumer<T>
asJavaConsumer
(Consumer<T> wrapped) Returns ajava.util.function.Consumer
which wraps the specifiedConsumer
and throws any thrown exceptions.static <T> Consumer<T>
asJavaConsumerIgnoreException
(Consumer<T> wrapped) Returns ajava.util.function.Consumer
which wraps the specifiedConsumer
and discards any thrownException
s.
-
Method Details
-
accept
Applies this function to the specified argument.- Parameters:
t
- The input to this function.- Throws:
Exception
- An exception thrown by the method.
-
andThen
Compose the specifiedConsumer
to be called after thisConsumer
.- Parameters:
after
- TheConsumer
to be called after thisConsumer
is called. Must not benull
.- Returns:
- A
Consumer
composed of thisConsumer
and the specifiedConsumer
.
-
asJavaConsumer
Returns ajava.util.function.Consumer
which wraps the specifiedConsumer
and throws any thrown exceptions.The returned
java.util.function.Consumer
will throw any exception thrown by the wrappedConsumer
.- Type Parameters:
T
- The type of the function input.- Parameters:
wrapped
- TheConsumer
to wrap. Must not benull
.- Returns:
- A
java.util.function.Consumer
which wraps the specifiedConsumer
.
-
asJavaConsumerIgnoreException
Returns ajava.util.function.Consumer
which wraps the specifiedConsumer
and discards any thrownException
s.The returned
java.util.function.Consumer
will discard anyException
thrown by the wrappedConsumer
.- Type Parameters:
T
- The type of the function input.- Parameters:
wrapped
- TheConsumer
to wrap. Must not benull
.- Returns:
- A
java.util.function.Consumer
which wraps the specifiedConsumer
.
-
asConsumer
Returns aConsumer
which wraps ajava.util.function.Consumer
.- Type Parameters:
T
- The type of the function input.- Parameters:
wrapped
- Thejava.util.function.Consumer
to wrap. Must not benull
.- Returns:
- A
Consumer
which wraps the specifiedjava.util.function.Consumer
.
-