Object
Curry
Set of functions for implementing currying in Java.
For example imagine you have a bifunction like:
String m(String s, Integer i)
And you want to create a function from it which will be calling m with specific second argument
(ex. 5).
Instead of writing:
list.stream()
.map(s -> m(s, 5))
.collect(toList());
You can do:
list.stream()
.map(curry2nd(this.m, 5))
.collect(toList());
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,
E extends Exception>
ThrowingRunnable<E> curryAccept
(ThrowingConsumer<T, E> consumer, T v) Curry argument for Consumerstatic <T1,
T2, E extends Exception>
ThrowingConsumer<T2, E> curryAccept1st
(ThrowingBiConsumer<T1, T2, E> consumer, T1 t1) Curry 1st argument for a BiConsumerstatic <T1,
T2, R, E extends Exception>
ThrowingConsumer<T1, E> curryAccept2nd
(ThrowingBiConsumer<T1, T2, E> consumer, T2 t2) Curry 2nd argument for a BiConsumerstatic <T1,
T2, R, E extends Exception>
ThrowingFunction<T2, R, E> curryApply1st
(ThrowingBiFunction<T1, T2, R, E> function, T1 t1) Curry 1st argument for a BiFunctionstatic <T1,
T2, R, E extends Exception>
ThrowingFunction<T1, R, E> curryApply2nd
(ThrowingBiFunction<T1, T2, R, E> function, T2 t2) Curry 2nd argument for a BiFunction
-
Constructor Details
-
Curry
public Curry()
-
-
Method Details
-
curryAccept
public static <T,E extends Exception> ThrowingRunnable<E> curryAccept(ThrowingConsumer<T, E> consumer, T v) Curry argument for Consumer -
curryApply1st
public static <T1,T2, ThrowingFunction<T2,R, E extends Exception> R, curryApply1stE> (ThrowingBiFunction<T1, T2, R, E> function, T1 t1) Curry 1st argument for a BiFunction -
curryApply2nd
public static <T1,T2, ThrowingFunction<T1,R, E extends Exception> R, curryApply2ndE> (ThrowingBiFunction<T1, T2, R, E> function, T2 t2) Curry 2nd argument for a BiFunction -
curryAccept1st
public static <T1,T2, ThrowingConsumer<T2,E extends Exception> E> curryAccept1st(ThrowingBiConsumer<T1, T2, E> consumer, T1 t1) Curry 1st argument for a BiConsumer -
curryAccept2nd
public static <T1,T2, ThrowingConsumer<T1,R, E extends Exception> E> curryAccept2nd(ThrowingBiConsumer<T1, T2, E> consumer, T2 t2) Curry 2nd argument for a BiConsumer
-