On this page

FailableFunction

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

A functional interface like Function that declares a Throwable.

Type parameters:
  • <T> – Input type 1.

  • <R> – Return type.

  • <E> – The type of thrown exception or error.

Since:

3.11

Fields and constants

static final FailableFunction

NOP

NOP singleton

static final FailableFunction NOP[source]

NOP singleton

Methods

default <V> FailableFunction<T, V, E>

andThen(FailableFunction<? super R, ? extends V, E> after)

Returns a composed FailableFunction like Function.andThen(Function).

R

apply(T input)

Applies this function.

default <V> FailableFunction<V, R, E>

compose(FailableFunction<? super V, ? extends T, E> before)

Returns a composed FailableFunction like Function.compose(Function).

static <T, R, E extends Throwable> FailableFunction<T, R, E>

function(FailableFunction<T, R, E> function)

Starts a fluent chain like function(foo::bar).andThen(...).andThen(...).apply(...);

static <T, E extends Throwable> FailableFunction<T, T, E>

identity()

Returns a function that always returns its input argument.

static <T, R, E extends Throwable> FailableFunction<T, R, E>

nop()

Gets the NOP singleton.

default <V> FailableFunction<T, V, E> andThen(FailableFunction<? super R, ? extends V, E> after)[source]

Returns a composed FailableFunction like Function.andThen(Function).

Type parameters:

<V> – The output type of the after function, and of the composed function.

Parameters:

after – The operation to perform after this one.

Returns:

A composed FailableFunction like Function.andThen(Function).

Throws:

NullPointerException – Thrown when after is null.

R apply(T input) throws E[source]

Applies this function.

Parameters:

input – The input for the function

Returns:

The result of the function

Throws:

E – Thrown when the function fails.

default <V> FailableFunction<V, R, E> compose(FailableFunction<? super V, ? extends T, E> before)[source]

Returns a composed FailableFunction like Function.compose(Function).

Type parameters:

<V> – The input type to the before function, and to the composed function.

Parameters:

before – The operator to apply before this one.

Returns:

A composed FailableFunction like Function.compose(Function).

Throws:

NullPointerException – Thrown if before is null.

See also:

andThen(FailableFunction)

static <T, R, E extends Throwable> FailableFunction<T, R, E> function(FailableFunction<T, R, E> function)[source]

Starts a fluent chain like function(foo::bar).andThen(...).andThen(...).apply(...);

Type parameters:
  • <T> – Input type.

  • <R> – Return type.

  • <E> – The type of thrown exception or error.

Parameters:

function – The argument to return.

Returns:

The argument

Since:

3.14.0

static <T, E extends Throwable> FailableFunction<T, T, E> identity()[source]

Returns a function that always returns its input argument.

Type parameters:
  • <T> – The type of the input and output objects to the function

  • <E> – The type of thrown exception or error.

Returns:

A function that always returns its input argument

static <T, R, E extends Throwable> FailableFunction<T, R, E> nop()[source]

Gets the NOP singleton.

Type parameters:
  • <T> – Consumed type.

  • <R> – Return type.

  • <E> – The type of thrown exception or error.

Returns:

The NOP singleton.