Interface Functions


public interface Functions
Utility class containing some functional programming helper functions.
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static <A1, A2, R>
    Function<A2,Function<A1,R>>
    backCurried(BiFunction<A1,A2,R> f)
    Converts a function that takes two arguments to its curried version with reversed arguments.
    static <A1, A2, R>
    Function<A1,Function<A2,R>>
    curried(BiFunction<A1,A2,R> f)
    Converts a function that takes two arguments to its curried version.
    static <T> Function<Object,Optional<T>>
    maybeCast(Class<T> clazz)
    Returns function that conditionally casts an object to a given class, returning an empty optional if the cast fails.
  • Method Details

    • curried

      static <A1, A2, R> Function<A1,Function<A2,R>> curried(BiFunction<A1,A2,R> f)
      Converts a function that takes two arguments to its curried version.
      Type Parameters:
      A1 - the first argument type
      A2 - the second argument type
      R - the return type
      Parameters:
      f - the function to be curried
      Returns:
      the curried function
    • backCurried

      static <A1, A2, R> Function<A2,Function<A1,R>> backCurried(BiFunction<A1,A2,R> f)
      Converts a function that takes two arguments to its curried version with reversed arguments.
      Type Parameters:
      A1 - the first argument type
      A2 - the second argument type
      R - the return type
      Parameters:
      f - the function to be curried
      Returns:
      the curried function
    • maybeCast

      static <T> Function<Object,Optional<T>> maybeCast(Class<T> clazz)
      Returns function that conditionally casts an object to a given class, returning an empty optional if the cast fails.
      Type Parameters:
      T - the class to cast to
      Parameters:
      clazz - the class to cast to
      Returns:
      the function