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 void
accept(T t)
Applies this function to the specified argument.default Consumer<T>
andThen(Consumer<? super T> after)
Compose the specifiedConsumer
to be called after thisConsumer
.static <T> Consumer<T>
asConsumer(java.util.function.Consumer<T> wrapped)
Returns aConsumer
which wraps ajava.util.function.Consumer
.static <T> java.util.function.Consumer<T>
asJavaConsumer(Consumer<T> wrapped)
Returns ajava.util.function.Consumer
which wraps the specifiedConsumer
and throws any thrown exceptions.static <T> java.util.function.Consumer<T>
asJavaConsumerIgnoreException(Consumer<T> wrapped)
Returns ajava.util.function.Consumer
which wraps the specifiedConsumer
and discards any thrownException
s.
-
-
-
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 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
static <T> java.util.function.Consumer<T> asJavaConsumer(Consumer<T> wrapped)
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
static <T> java.util.function.Consumer<T> asJavaConsumerIgnoreException(Consumer<T> wrapped)
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
static <T> Consumer<T> asConsumer(java.util.function.Consumer<T> wrapped)
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
.
-
-