Package dev.alexengrig.util.lambda
Class Currying
java.lang.Object
dev.alexengrig.util.lambda.Currying
Currying
is the technique of converting a function
that takes multiple arguments into a sequence of functions.
Parts of method name:
left- arguments from left to right;right- arguments from right to left;middle- arguments from middle;all- all arguments;2-BiFunctionas the function;3-TerFunctionas the function;bi-BiFunctionas the result.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Grig Alex
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <F,R> Supplier<R> Currying from:static <F,S, R> Supplier<R> all2(BiFunction<F, S, R> biFunction, F first, S second) Currying from:static <F,S, T, R> Supplier<R> all3(TerFunction<F, S, T, R> terFunction, F first, S second, T third) Currying from:static <F,S, T, R> BiFunction<S, T, R> biLeft3(TerFunction<F, S, T, R> terFunction, F first) Currying from:static <F,S, T, R> BiFunction<F, T, R> biMiddle3(TerFunction<F, S, T, R> terFunction, S second) Currying from:static <F,S, T, R> BiFunction<F, S, R> biRight3(TerFunction<F, S, T, R> terFunction, T third) Currying from:left2(BiFunction<F, S, R> biFunction) Currying from:static <F,S, R> Function<S, R> left2(BiFunction<F, S, R> biFunction, F first) Currying from:left3(TerFunction<F, S, T, R> terFunction) Currying from:left3(TerFunction<F, S, T, R> terFunction, F first) Currying from:static <F,S, T, R> Function<T, R> left3(TerFunction<F, S, T, R> terFunction, F first, S second) Currying from:leftMiddle3(TerFunction<F, S, T, R> terFunction, S second) Currying from:static <F,S, T, R> Function<S, R> middle3(TerFunction<F, S, T, R> terFunction, F first, T third) Currying from:right2(BiFunction<F, S, R> biFunction) Currying from:static <F,S, R> Function<F, R> right2(BiFunction<F, S, R> biFunction, S second) Currying from:right3(TerFunction<F, S, T, R> terFunction) Currying from:static <F,S, T, R> Function<F, R> right3(TerFunction<F, S, T, R> terFunction, S second, T third) Currying from:right3(TerFunction<F, S, T, R> terFunction, T third) Currying from:rightMiddle3(TerFunction<F, S, T, R> terFunction, S second) Currying from:
-
Method Details
-
left2
Currying from:
to:(first, second) -> result(first) -> (second) -> result- Type Parameters:
F- the type of the first argument tobiFunctionS- the type of the second argument tobiFunctionR- the type of the result ofbiFunction- Parameters:
biFunction- the function for currying- Returns:
- currying of
biFunction - Throws:
NullPointerException- ifbiFunctionis null- Since:
- 1.0
-
left2
Currying from:
to:(first, second) -> result(second) -> result- Type Parameters:
F- the type of the first argument tobiFunctionS- the type of the second argument tobiFunctionR- the type of the result ofbiFunction- Parameters:
biFunction- the function for curryingfirst- the value of the first argument tobiFunction- Returns:
- currying of
biFunction - Throws:
NullPointerException- ifbiFunctionis null- Since:
- 1.0
-
left3
public static <F,S, Function<F,T, R> Function<S, left3Function<T, R>>> (TerFunction<F, S, T, R> terFunction) Currying from:
to:(first, second, third) -> result(first) -> (second) -> (third) -> result- Type Parameters:
F- the type of the first argument toterFunctionS- the type of the second argument toterFunctionT- the type of the third argument toterFunctionR- the type of the result ofterFunction- Parameters:
terFunction- the function for currying- Returns:
- currying of
terFunction - Throws:
NullPointerException- ifterFunctionis null- Since:
- 1.0
-
left3
public static <F,S, Function<S,T, R> Function<T, left3R>> (TerFunction<F, S, T, R> terFunction, F first) Currying from:
to:(first, second, third) -> result(second) -> (third) -> result- Type Parameters:
F- the type of the first argument toterFunctionS- the type of the second argument toterFunctionT- the type of the third argument toterFunctionR- the type of the result ofterFunction- Parameters:
terFunction- the function for curryingfirst- the value of the first argument toterFunction- Returns:
- currying of
terFunction - Throws:
NullPointerException- ifterFunctionis null- Since:
- 1.0
-
left3
Currying from:
to:(first, second, third) -> result(third) -> result- Type Parameters:
F- the type of the first argument toterFunctionS- the type of the second argument toterFunctionT- the type of the third argument toterFunctionR- the type of the result ofterFunction- Parameters:
terFunction- the function for curryingfirst- the value of the first argument toterFunctionsecond- the value of the second argument toterFunction- Returns:
- currying of
terFunction - Throws:
NullPointerException- ifterFunctionis null- Since:
- 1.0
-
leftMiddle3
public static <F,S, Function<F,T, R> Function<T, leftMiddle3R>> (TerFunction<F, S, T, R> terFunction, S second) Currying from:
to:(first, second, third) -> result(first) -> (third) -> result- Type Parameters:
F- the type of the first argument toterFunctionS- the type of the second argument toterFunctionT- the type of the third argument toterFunctionR- the type of the result ofterFunction- Parameters:
terFunction- the function for curryingsecond- the value of the second argument toterFunction- Returns:
- currying of
terFunction - Throws:
NullPointerException- ifterFunctionis null- Since:
- 1.0
-
middle3
public static <F,S, Function<S,T, R> R> middle3(TerFunction<F, S, T, R> terFunction, F first, T third) Currying from:
to:(first, second, third) -> result(second) -> result- Type Parameters:
F- the type of the first argument toterFunctionS- the type of the second argument toterFunctionT- the type of the third argument toterFunctionR- the type of the result ofterFunction- Parameters:
terFunction- the function for curryingfirst- the value of the first argument toterFunctionthird- the value of the third argument toterFunction- Returns:
- currying of
terFunction - Throws:
NullPointerException- ifterFunctionis null- Since:
- 1.0
-
rightMiddle3
public static <F,S, Function<T,T, R> Function<F, rightMiddle3R>> (TerFunction<F, S, T, R> terFunction, S second) Currying from:
to:(first, second, third) -> result(third) -> (first) -> result- Type Parameters:
F- the type of the first argument toterFunctionS- the type of the second argument toterFunctionT- the type of the third argument toterFunctionR- the type of the result ofterFunction- Parameters:
terFunction- the function for curryingsecond- the value of the second argument toterFunction- Returns:
- currying of
terFunction - Throws:
NullPointerException- ifterFunctionis null- Since:
- 1.0
-
right2
Currying from:
to:(first, second) -> result(second) -> (first) -> result- Type Parameters:
F- the type of the first argument tobiFunctionS- the type of the second argument tobiFunctionR- the type of the result ofbiFunction- Parameters:
biFunction- the function for currying- Returns:
- currying of
biFunction - Throws:
NullPointerException- ifbiFunctionis null- Since:
- 1.0
-
right2
Currying from:
to:(first, second) -> result(first) -> result- Type Parameters:
F- the type of the first argument tobiFunctionS- the type of the second argument tobiFunctionR- the type of the result ofbiFunction- Parameters:
biFunction- the function for curryingsecond- the value of the second argument tobiFunction- Returns:
- currying of
biFunction - Throws:
NullPointerException- ifbiFunctionis null- Since:
- 1.0
-
right3
public static <F,S, Function<T,T, R> Function<S, right3Function<F, R>>> (TerFunction<F, S, T, R> terFunction) Currying from:
to:(first, second, third) -> result(third) -> (second) -> (first) -> result- Type Parameters:
F- the type of the first argument toterFunctionS- the type of the second argument toterFunctionT- the type of the third argument toterFunctionR- the type of the result ofterFunction- Parameters:
terFunction- the function for currying- Returns:
- currying of
terFunction - Throws:
NullPointerException- ifterFunctionis null- Since:
- 1.0
-
right3
public static <F,S, Function<S,T, R> Function<F, right3R>> (TerFunction<F, S, T, R> terFunction, T third) Currying from:
to:(first, second, third) -> result(second) -> (first) -> result- Type Parameters:
F- the type of the first argument toterFunctionS- the type of the second argument toterFunctionT- the type of the third argument toterFunctionR- the type of the result ofterFunction- Parameters:
terFunction- the function for curryingthird- the value of the third argument toterFunction- Returns:
- currying of
terFunction - Throws:
NullPointerException- ifterFunctionis null- Since:
- 1.0
-
right3
public static <F,S, Function<F,T, R> R> right3(TerFunction<F, S, T, R> terFunction, S second, T third) Currying from:
to:(first, second, third) -> result(first) -> result- Type Parameters:
F- the type of the first argument toterFunctionS- the type of the second argument toterFunctionT- the type of the third argument toterFunctionR- the type of the result ofterFunction- Parameters:
terFunction- the function for curryingthird- the value of the third argument toterFunctionsecond- the value of the second argument toterFunction- Returns:
- currying of
terFunction - Throws:
NullPointerException- ifterFunctionis null- Since:
- 1.0
-
biLeft3
Currying from:
to:(first, second, third) -> result(second, third) -> result- Type Parameters:
F- the type of the first argument toterFunctionS- the type of the second argument toterFunctionT- the type of the third argument toterFunctionR- the type of the result ofterFunction- Parameters:
terFunction- the function for curryingfirst- the value of the first argument toterFunction- Returns:
- currying of
terFunction - Throws:
NullPointerException- ifterFunctionis null- Since:
- 1.0
-
biMiddle3
Currying from:
to:(first, second, third) -> result(first, third) -> result- Type Parameters:
F- the type of the first argument toterFunctionS- the type of the second argument toterFunctionT- the type of the third argument toterFunctionR- the type of the result ofterFunction- Parameters:
terFunction- the function for curryingsecond- the value of the second argument toterFunction- Returns:
- currying of
terFunction - Throws:
NullPointerException- ifterFunctionis null- Since:
- 1.0
-
biRight3
Currying from:
to:(first, second, third) -> result(first, second) -> result- Type Parameters:
F- the type of the first argument toterFunctionS- the type of the second argument toterFunctionT- the type of the third argument toterFunctionR- the type of the result ofterFunction- Parameters:
terFunction- the function for curryingthird- the value of the third argument toterFunction- Returns:
- currying of
terFunction - Throws:
NullPointerException- ifterFunctionis null- Since:
- 1.0
-
all
Currying from:
to:(first) -> result() -> result- Type Parameters:
F- the type of the first argument tofunctionR- the type of the result offunction- Parameters:
function- the function for curryingfirst- the value of the first argument tofunction- Returns:
- currying of
function - Throws:
NullPointerException- iffunctionis null- Since:
- 1.0
-
all2
Currying from:
to:(first, second) -> result() -> result- Type Parameters:
F- the type of the first argument tobiFunctionR- the type of the result ofbiFunction- Parameters:
biFunction- the function for curryingfirst- the value of the first argument tobiFunctionsecond- the value of the second argument tobiFunction- Returns:
- currying of
biFunction - Throws:
NullPointerException- ifbiFunctionis null- Since:
- 1.0
-
all3
public static <F,S, Supplier<R> all3T, R> (TerFunction<F, S, T, R> terFunction, F first, S second, T third) Currying from:
to:(first, second, third) -> result() -> result- Type Parameters:
F- the type of the first argument toterFunctionR- the type of the result ofterFunction- Parameters:
terFunction- the function for curryingfirst- the value of the first argument toterFunctionsecond- the value of the second argument toterFunctionthird- the value of the third argument toterFunction- Returns:
- currying of
terFunction - Throws:
NullPointerException- ifterFunctionis null- Since:
- 1.0
-