T - the value type supplied to this consumer.@FunctionalInterface public interface CheckedConsumer<T>
| Modifier and Type | Method and Description |
|---|---|
void |
accept(T t)
Performs side-effects.
|
default CheckedConsumer<T> |
andThen(CheckedConsumer<? super T> after)
Returns a chained
CheckedConsumer that first executes this.accept(t)
and then after.accept(t), for a given t of type T. |
static <T> CheckedConsumer<T> |
of(CheckedConsumer<T> methodReference)
Creates a
CheckedConsumer. |
default Consumer<T> |
unchecked()
Returns an unchecked
Consumer that will sneaky throw if an exceptions occurs when accepting a value. |
static <T> CheckedConsumer<T> of(CheckedConsumer<T> methodReference)
CheckedConsumer.
final CheckedConsumer<Value> checkedConsumer = CheckedConsumer.of(Value::stdout);
final Consumer<Value> consumer = checkedConsumer.unchecked();
// prints "Hi" on the console
consumer.accept(CharSeq.of("Hi!"));
// throws
consumer.accept(null);
T - type of values that are accepted by the consumermethodReference - (typically) a method reference, e.g. Type::methodCheckedConsumerCheckedFunction1.of(CheckedFunction1)void accept(T t) throws Throwable
t - a value of type TThrowable - if an error occursdefault CheckedConsumer<T> andThen(CheckedConsumer<? super T> after)
CheckedConsumer that first executes this.accept(t)
and then after.accept(t), for a given t of type T.after - the action that will be executed after this actionCheckedConsumer that chains this and afterNullPointerException - if after is nullCopyright © 2019. All Rights Reserved.