On this page

FailableConsumer

@FunctionalInterface public abstract interface org.apache.commons.lang3.function.FailableConsumer<T, E extends Throwable>[source]

A functional interface like Consumer that declares a Throwable.

This is a functional interface whose functional method is #accept(Object).

Parameters:
  • <T> – The type of the argument the consumer accepts.

  • <E> – The thrown exception type.

Since:

3.11

Fields and constants

NOP

NOP singleton

@SuppressWarnings({"rawtypes"}) public static final FailableConsumer NOP[source]

NOP singleton

Methods

accept(Object)

Accepts the given arguments.

accept(FailableConsumer, Object)

Applies the given FailableConsumer action to the object if the consumer is not null.

andThen(FailableConsumer)

Returns a composed Consumer like Consumer#andThen(Consumer).

nop()

Gets the NOP singleton.

public abstract void accept(T object) throws E[source]

Accepts the given arguments.

Parameters:

object – The parameter for the consumable to accept

Throws:

E – Thrown when the consumer fails.

public static <T, E extends Throwable> void accept(FailableConsumer<T, E> consumer, T object) throws E[source]

Applies the given FailableConsumer action to the object if the consumer is not null. Otherwise, does nothing.

Parameters:
  • consumer – The consumer to consume.

  • object – The object to be consumed.

Type parameters:
  • <T> – the type of the argument the consumer accepts.

  • <E> – The thrown exception type.

Throws:

E – Thrown when the consumer fails.

Since:

3.21.0

public default FailableConsumer<T, E> andThen(FailableConsumer<? super T, E> after)[source]

Returns a composed Consumer like Consumer#andThen(Consumer).

Parameters:

after – The operation to perform after this operation

Returns:

A composed Consumer like Consumer#andThen(Consumer).

Throws:

java.lang.NullPointerException – Thrown when after is null.

@SuppressWarnings({"unchecked"}) public static <T, E extends Throwable> FailableConsumer<T, E> nop()[source]

Gets the NOP singleton.

Type parameters:
  • <T> – The type of the argument the consumer accepts.

  • <E> – The thrown exception type.

Returns:

The NOP singleton.