FailableFunction

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

A functional interface like Function that declares a Throwable.

Parameters:
  • <T> – Input type 1.

  • <R> – Return type.

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

Since:

3.11

Fields and constants

NOP

NOP singleton

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

NOP singleton

Methods

andThen(FailableFunction)

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

apply(Object)

Applies this function.

compose(FailableFunction)

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

function(FailableFunction)

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

identity()

Returns a function that always returns its input argument.

nop()

Gets the NOP singleton.

public 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.

Returns:

A composed FailableFunction like Function#andThen(Function).

Parameters:

after – The operation to perform after this one.

Throws:

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

public abstract 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.

public 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:

java.lang.NullPointerException – Thrown if before is null.

See also:

#andThen(FailableFunction)

public 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

public 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

@SuppressWarnings({"unchecked"}) public 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.