Package ratpack.func
Interface BiAction<T,U>
-
- Type Parameters:
T- the type of the first thingU- The type of the second thing
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface BiAction<T,U>
A generic type for an object that does some work with 2 input things.This type serves the same purpose as the JDK's
BiConsumer, but allows throwing checked exceptions. It contains methods for bridging to and from the JDK type.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidexecute(T t, U u)Executes the action against the given thing.static <T,U>
BiAction<T,U>from(BiConsumer<T,U> consumer)Creates an bi-action from a JDK bi-consumer.static <T,U>
BiAction<T,U>noop()Returns a bi-action that does precisely nothing.default BiConsumer<T,U>toBiConsumer()Creates a JDKBiConsumerfrom this action.
-
-
-
Method Detail
-
execute
void execute(T t, U u) throws Exception
Executes the action against the given thing.- Parameters:
t- the first thing to input to the actionu- the second thing to input to the action- Throws:
Exception- if anything goes wrong
-
noop
static <T,U> BiAction<T,U> noop()
Returns a bi-action that does precisely nothing.- Type Parameters:
T- the type of the first thingU- The type of the second thing- Returns:
- a bi-action that does precisely nothing
- Since:
- 1.5
-
toBiConsumer
default BiConsumer<T,U> toBiConsumer()
Creates a JDKBiConsumerfrom this action.Any exceptions thrown by
thisaction will be unchecked viaExceptions.uncheck(Throwable)and rethrown.- Returns:
- this function as a JDK style consumer.
-
from
static <T,U> BiAction<T,U> from(BiConsumer<T,U> consumer)
Creates an bi-action from a JDK bi-consumer.- Type Parameters:
T- the type of the first object this action acceptsU- the type of the second object this action accepts- Parameters:
consumer- the JDK consumer- Returns:
- the given consumer as an action
-
-