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.
@ConsumerType @FunctionalInterface public interface Consumer<T>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
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaccept(T t)Applies this function to the specified argument.default Consumer<T>andThen(Consumer<? super T> after)Compose the specifiedConsumerto be called after thisConsumer.static <T> Consumer<T>asConsumer(java.util.function.Consumer<T> wrapped)Returns aConsumerwhich wraps ajava.util.function.Consumer.static <T> java.util.function.Consumer<T>asJavaConsumer(Consumer<T> wrapped)Returns ajava.util.function.Consumerwhich wraps the specifiedConsumerand throws any thrown exceptions.static <T> java.util.function.Consumer<T>asJavaConsumerIgnoreException(Consumer<T> wrapped)Returns ajava.util.function.Consumerwhich wraps the specifiedConsumerand discards any thrownExceptions.
-
-
-
Method Detail
-
accept
void accept(T t) throws java.lang.Exception
Applies this function to the specified argument.- Parameters:
t- The input to this function.- Throws:
java.lang.Exception- An exception thrown by the method.
-
andThen
default Consumer<T> andThen(Consumer<? super T> after)
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
static <T> java.util.function.Consumer<T> asJavaConsumer(Consumer<T> wrapped)
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
static <T> java.util.function.Consumer<T> asJavaConsumerIgnoreException(Consumer<T> wrapped)
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
static <T> Consumer<T> asConsumer(java.util.function.Consumer<T> wrapped)
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.
-
-