Class Currying

java.lang.Object
dev.alexengrig.util.lambda.Currying

public final class Currying extends Object
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 - BiFunction as the function;
  • 3 - TerFunction as the function;
  • bi - BiFunction as the result.
Since:
1.0
Version:
1.0
Author:
Grig Alex
See Also:
  • Method Details

    • left2

      public static <F, S, R> Function<F,Function<S,R>> left2(BiFunction<F,S,R> biFunction)
      Currying from:
      
       (first, second) -> result
       
      to:
      
       (first) -> (second) -> result
       
      Type Parameters:
      F - the type of the first argument to biFunction
      S - the type of the second argument to biFunction
      R - the type of the result of biFunction
      Parameters:
      biFunction - the function for currying
      Returns:
      currying of biFunction
      Throws:
      NullPointerException - if biFunction is null
      Since:
      1.0
    • left2

      public static <F, S, R> Function<S,R> left2(BiFunction<F,S,R> biFunction, F first)
      Currying from:
      
       (first, second) -> result
       
      to:
      
       (second) -> result
       
      Type Parameters:
      F - the type of the first argument to biFunction
      S - the type of the second argument to biFunction
      R - the type of the result of biFunction
      Parameters:
      biFunction - the function for currying
      first - the value of the first argument to biFunction
      Returns:
      currying of biFunction
      Throws:
      NullPointerException - if biFunction is null
      Since:
      1.0
    • left3

      public static <F, S, T, R> Function<F,Function<S,Function<T,R>>> left3(TerFunction<F,S,T,R> terFunction)
      Currying from:
      
       (first, second, third) -> result
       
      to:
      
       (first) -> (second) -> (third) -> result
       
      Type Parameters:
      F - the type of the first argument to terFunction
      S - the type of the second argument to terFunction
      T - the type of the third argument to terFunction
      R - the type of the result of terFunction
      Parameters:
      terFunction - the function for currying
      Returns:
      currying of terFunction
      Throws:
      NullPointerException - if terFunction is null
      Since:
      1.0
    • left3

      public static <F, S, T, R> Function<S,Function<T,R>> left3(TerFunction<F,S,T,R> terFunction, F first)
      Currying from:
      
       (first, second, third) -> result
       
      to:
      
       (second) -> (third) -> result
       
      Type Parameters:
      F - the type of the first argument to terFunction
      S - the type of the second argument to terFunction
      T - the type of the third argument to terFunction
      R - the type of the result of terFunction
      Parameters:
      terFunction - the function for currying
      first - the value of the first argument to terFunction
      Returns:
      currying of terFunction
      Throws:
      NullPointerException - if terFunction is null
      Since:
      1.0
    • left3

      public static <F, S, T, R> Function<T,R> left3(TerFunction<F,S,T,R> terFunction, F first, S second)
      Currying from:
      
       (first, second, third) -> result
       
      to:
      
       (third) -> result
       
      Type Parameters:
      F - the type of the first argument to terFunction
      S - the type of the second argument to terFunction
      T - the type of the third argument to terFunction
      R - the type of the result of terFunction
      Parameters:
      terFunction - the function for currying
      first - the value of the first argument to terFunction
      second - the value of the second argument to terFunction
      Returns:
      currying of terFunction
      Throws:
      NullPointerException - if terFunction is null
      Since:
      1.0
    • leftMiddle3

      public static <F, S, T, R> Function<F,Function<T,R>> leftMiddle3(TerFunction<F,S,T,R> terFunction, S second)
      Currying from:
      
       (first, second, third) -> result
       
      to:
      
       (first) -> (third) -> result
       
      Type Parameters:
      F - the type of the first argument to terFunction
      S - the type of the second argument to terFunction
      T - the type of the third argument to terFunction
      R - the type of the result of terFunction
      Parameters:
      terFunction - the function for currying
      second - the value of the second argument to terFunction
      Returns:
      currying of terFunction
      Throws:
      NullPointerException - if terFunction is null
      Since:
      1.0
    • middle3

      public static <F, S, T, R> Function<S,R> middle3(TerFunction<F,S,T,R> terFunction, F first, T third)
      Currying from:
      
       (first, second, third) -> result
       
      to:
      
       (second) ->  result
       
      Type Parameters:
      F - the type of the first argument to terFunction
      S - the type of the second argument to terFunction
      T - the type of the third argument to terFunction
      R - the type of the result of terFunction
      Parameters:
      terFunction - the function for currying
      first - the value of the first argument to terFunction
      third - the value of the third argument to terFunction
      Returns:
      currying of terFunction
      Throws:
      NullPointerException - if terFunction is null
      Since:
      1.0
    • rightMiddle3

      public static <F, S, T, R> Function<T,Function<F,R>> rightMiddle3(TerFunction<F,S,T,R> terFunction, S second)
      Currying from:
      
       (first, second, third) -> result
       
      to:
      
       (third) -> (first) ->  result
       
      Type Parameters:
      F - the type of the first argument to terFunction
      S - the type of the second argument to terFunction
      T - the type of the third argument to terFunction
      R - the type of the result of terFunction
      Parameters:
      terFunction - the function for currying
      second - the value of the second argument to terFunction
      Returns:
      currying of terFunction
      Throws:
      NullPointerException - if terFunction is null
      Since:
      1.0
    • right2

      public static <F, S, R> Function<S,Function<F,R>> right2(BiFunction<F,S,R> biFunction)
      Currying from:
      
       (first, second) -> result
       
      to:
      
       (second) -> (first) -> result
       
      Type Parameters:
      F - the type of the first argument to biFunction
      S - the type of the second argument to biFunction
      R - the type of the result of biFunction
      Parameters:
      biFunction - the function for currying
      Returns:
      currying of biFunction
      Throws:
      NullPointerException - if biFunction is null
      Since:
      1.0
    • right2

      public static <F, S, R> Function<F,R> right2(BiFunction<F,S,R> biFunction, S second)
      Currying from:
      
       (first, second) -> result
       
      to:
      
       (first) -> result
       
      Type Parameters:
      F - the type of the first argument to biFunction
      S - the type of the second argument to biFunction
      R - the type of the result of biFunction
      Parameters:
      biFunction - the function for currying
      second - the value of the second argument to biFunction
      Returns:
      currying of biFunction
      Throws:
      NullPointerException - if biFunction is null
      Since:
      1.0
    • right3

      public static <F, S, T, R> Function<T,Function<S,Function<F,R>>> right3(TerFunction<F,S,T,R> terFunction)
      Currying from:
      
       (first, second, third) -> result
       
      to:
      
       (third) -> (second) -> (first) ->  result
       
      Type Parameters:
      F - the type of the first argument to terFunction
      S - the type of the second argument to terFunction
      T - the type of the third argument to terFunction
      R - the type of the result of terFunction
      Parameters:
      terFunction - the function for currying
      Returns:
      currying of terFunction
      Throws:
      NullPointerException - if terFunction is null
      Since:
      1.0
    • right3

      public static <F, S, T, R> Function<S,Function<F,R>> right3(TerFunction<F,S,T,R> terFunction, T third)
      Currying from:
      
       (first, second, third) -> result
       
      to:
      
       (second) -> (first) ->  result
       
      Type Parameters:
      F - the type of the first argument to terFunction
      S - the type of the second argument to terFunction
      T - the type of the third argument to terFunction
      R - the type of the result of terFunction
      Parameters:
      terFunction - the function for currying
      third - the value of the third argument to terFunction
      Returns:
      currying of terFunction
      Throws:
      NullPointerException - if terFunction is null
      Since:
      1.0
    • right3

      public static <F, S, T, R> Function<F,R> right3(TerFunction<F,S,T,R> terFunction, S second, T third)
      Currying from:
      
       (first, second, third) -> result
       
      to:
      
       (first) ->  result
       
      Type Parameters:
      F - the type of the first argument to terFunction
      S - the type of the second argument to terFunction
      T - the type of the third argument to terFunction
      R - the type of the result of terFunction
      Parameters:
      terFunction - the function for currying
      third - the value of the third argument to terFunction
      second - the value of the second argument to terFunction
      Returns:
      currying of terFunction
      Throws:
      NullPointerException - if terFunction is null
      Since:
      1.0
    • biLeft3

      public static <F, S, T, R> BiFunction<S,T,R> biLeft3(TerFunction<F,S,T,R> terFunction, F first)
      Currying from:
      
       (first, second, third) -> result
       
      to:
      
       (second, third) ->  result
       
      Type Parameters:
      F - the type of the first argument to terFunction
      S - the type of the second argument to terFunction
      T - the type of the third argument to terFunction
      R - the type of the result of terFunction
      Parameters:
      terFunction - the function for currying
      first - the value of the first argument to terFunction
      Returns:
      currying of terFunction
      Throws:
      NullPointerException - if terFunction is null
      Since:
      1.0
    • biMiddle3

      public static <F, S, T, R> BiFunction<F,T,R> biMiddle3(TerFunction<F,S,T,R> terFunction, S second)
      Currying from:
      
       (first, second, third) -> result
       
      to:
      
       (first, third) ->  result
       
      Type Parameters:
      F - the type of the first argument to terFunction
      S - the type of the second argument to terFunction
      T - the type of the third argument to terFunction
      R - the type of the result of terFunction
      Parameters:
      terFunction - the function for currying
      second - the value of the second argument to terFunction
      Returns:
      currying of terFunction
      Throws:
      NullPointerException - if terFunction is null
      Since:
      1.0
    • biRight3

      public static <F, S, T, R> BiFunction<F,S,R> biRight3(TerFunction<F,S,T,R> terFunction, T third)
      Currying from:
      
       (first, second, third) -> result
       
      to:
      
       (first, second) ->  result
       
      Type Parameters:
      F - the type of the first argument to terFunction
      S - the type of the second argument to terFunction
      T - the type of the third argument to terFunction
      R - the type of the result of terFunction
      Parameters:
      terFunction - the function for currying
      third - the value of the third argument to terFunction
      Returns:
      currying of terFunction
      Throws:
      NullPointerException - if terFunction is null
      Since:
      1.0
    • all

      public static <F, R> Supplier<R> all(Function<F,R> function, F first)
      Currying from:
      
       (first) -> result
       
      to:
      
       () ->  result
       
      Type Parameters:
      F - the type of the first argument to function
      R - the type of the result of function
      Parameters:
      function - the function for currying
      first - the value of the first argument to function
      Returns:
      currying of function
      Throws:
      NullPointerException - if function is null
      Since:
      1.0
    • all2

      public static <F, S, R> Supplier<R> all2(BiFunction<F,S,R> biFunction, F first, S second)
      Currying from:
      
       (first, second) -> result
       
      to:
      
       () ->  result
       
      Type Parameters:
      F - the type of the first argument to biFunction
      R - the type of the result of biFunction
      Parameters:
      biFunction - the function for currying
      first - the value of the first argument to biFunction
      second - the value of the second argument to biFunction
      Returns:
      currying of biFunction
      Throws:
      NullPointerException - if biFunction is null
      Since:
      1.0
    • all3

      public static <F, S, T, R> Supplier<R> all3(TerFunction<F,S,T,R> terFunction, F first, S second, T third)
      Currying from:
      
       (first, second, third) -> result
       
      to:
      
       () ->  result
       
      Type Parameters:
      F - the type of the first argument to terFunction
      R - the type of the result of terFunction
      Parameters:
      terFunction - the function for currying
      first - the value of the first argument to terFunction
      second - the value of the second argument to terFunction
      third - the value of the third argument to terFunction
      Returns:
      currying of terFunction
      Throws:
      NullPointerException - if terFunction is null
      Since:
      1.0