Class Functional

java.lang.Object
com.complexible.common.base.Functional

public class Functional extends Object
Functional utilities
  • Constructor Details

    • Functional

      public Functional()
  • Method Details

    • mapEntryBiFunction

      public static <K, V, R> Function<Map.Entry<K,V>,R> mapEntryBiFunction(BiFunction<K,V,R> mapper)
      Transform a BiFunction to operate over a Map.Entry
    • mapEntryBiConsumer

      public static <K, V> Consumer<Map.Entry<K,V>> mapEntryBiConsumer(BiConsumer<K,V> consumer)
      Transform a BiConsumer to accept Map.Entry
    • wrapPartialWithIdentity

      public static <T> UnaryOperator<T> wrapPartialWithIdentity(UnaryOperator<T> partialFunction)
      Transform partial function to a total function by falling back to identity when the input is not mapped.
    • wrapPartial

      public static <T, R> Function<T,R> wrapPartial(Function<T,R> partialFunction, Function<T,R> ifNullFunction)
      Wrap a partial function (a function that can return null) with another function that replaces nulls.
    • compose

      public static <A, B, C> Function<A,C> compose(Function<? super B,C> g, Function<? super A,? extends B> f)
      Function composition as a static method which is more convenient than casting a lambda and calling Function.compose(Function).
    • negate

      public static <T> Predicate<T> negate(Predicate<T> p)
      Predicate negation as a static method which is more convenient than casting a lambda and calling Predicate.negate().
    • negate

      public static BooleanSupplier negate(BooleanSupplier p)
      BooleanSupplier negation as a static method.
    • throwingCombiner

      public static <T> BinaryOperator<T> throwingCombiner()
      A binary operator to be used with non-parallel Stream.reduce(Object, BiFunction, BinaryOperator) calls when a combiner is not needed.