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 TypeMethodDescriptionvoidApplies this function to the specified argument.Compose the specifiedConsumerto be called after thisConsumer.static <T> Consumer<T>asConsumer(Consumer<T> wrapped) Returns aConsumerwhich wraps ajava.util.function.Consumer.static <T> Consumer<T>asJavaConsumer(Consumer<T> wrapped) Returns ajava.util.function.Consumerwhich wraps the specifiedConsumerand throws any thrown exceptions.static <T> Consumer<T>asJavaConsumerIgnoreException(Consumer<T> wrapped) Returns ajava.util.function.Consumerwhich wraps the specifiedConsumerand discards any thrownExceptions.
-
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 specifiedConsumerto be called after thisConsumer.- Parameters:
after- TheConsumerto be called after thisConsumeris called. Must not benull.- Returns:
- A
Consumercomposed of thisConsumerand the specifiedConsumer.
-
asJavaConsumer
Returns ajava.util.function.Consumerwhich wraps the specifiedConsumerand throws any thrown exceptions.The returned
java.util.function.Consumerwill throw any exception thrown by the wrappedConsumer.- Type Parameters:
T- The type of the function input.- Parameters:
wrapped- TheConsumerto wrap. Must not benull.- Returns:
- A
java.util.function.Consumerwhich wraps the specifiedConsumer.
-
asJavaConsumerIgnoreException
Returns ajava.util.function.Consumerwhich wraps the specifiedConsumerand discards any thrownExceptions.The returned
java.util.function.Consumerwill discard anyExceptionthrown by the wrappedConsumer.- Type Parameters:
T- The type of the function input.- Parameters:
wrapped- TheConsumerto wrap. Must not benull.- Returns:
- A
java.util.function.Consumerwhich wraps the specifiedConsumer.
-
asConsumer
Returns aConsumerwhich wraps ajava.util.function.Consumer.- Type Parameters:
T- The type of the function input.- Parameters:
wrapped- Thejava.util.function.Consumerto wrap. Must not benull.- Returns:
- A
Consumerwhich wraps the specifiedjava.util.function.Consumer.
-