T
- The type of the function input.@ConsumerType @FunctionalInterface public interface Consumer<T>
This is a functional interface and can be used as the assignment target for a lambda expression or method reference.
Modifier and Type | Method and Description |
---|---|
void |
accept(T t)
Applies this function to the specified argument.
|
default Consumer<T> |
andThen(Consumer<? super T> after)
Compose the specified
Consumer to be called after this
Consumer . |
static <T> Consumer<T> |
asConsumer(Consumer<T> wrapped)
Returns a
Consumer which wraps a
java.util.function.Consumer . |
static <T> Consumer<T> |
asJavaConsumer(Consumer<T> wrapped)
Returns a
java.util.function.Consumer which wraps the specified
Consumer and throws any thrown exceptions. |
static <T> Consumer<T> |
asJavaConsumerIgnoreException(Consumer<T> wrapped)
Returns a
java.util.function.Consumer which wraps the specified
Consumer and discards any thrown Exception s. |
void accept(T t) throws Exception
t
- The input to this function.Exception
- An exception thrown by the method.default Consumer<T> andThen(Consumer<? super T> after)
Consumer
to be called after this
Consumer
.after
- The Consumer
to be called after this
Consumer
is called. Must not be null
.Consumer
composed of this Consumer
and the
specified Consumer
.static <T> Consumer<T> asJavaConsumer(Consumer<T> wrapped)
java.util.function.Consumer
which wraps the specified
Consumer
and throws any thrown exceptions.
The returned java.util.function.Consumer
will throw any exception
thrown by the wrapped Consumer
.
T
- The type of the function input.wrapped
- The Consumer
to wrap. Must not be null
.java.util.function.Consumer
which wraps the specified
Consumer
.static <T> Consumer<T> asJavaConsumerIgnoreException(Consumer<T> wrapped)
java.util.function.Consumer
which wraps the specified
Consumer
and discards any thrown Exception
s.
The returned java.util.function.Consumer
will discard any
Exception
thrown by the wrapped Consumer
.
T
- The type of the function input.wrapped
- The Consumer
to wrap. Must not be null
.java.util.function.Consumer
which wraps the specified
Consumer
.static <T> Consumer<T> asConsumer(Consumer<T> wrapped)
Consumer
which wraps a
java.util.function.Consumer
.T
- The type of the function input.wrapped
- The java.util.function.Consumer
to wrap. Must not
be null
.Consumer
which wraps the specified
java.util.function.Consumer
.Copyright © Contributors to the Eclipse Foundation Licensed under the Eclipse Foundation Specification License – v1.0