Class Functional


  • public class Functional
    extends java.lang.Object
    Functional utilities
    • Constructor Summary

      Constructors 
      Constructor Description
      Functional()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <A,​B,​C>
      java.util.function.Function<A,​C>
      compose​(java.util.function.Function<? super B,​C> g, java.util.function.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).
      static <K,​V>
      java.util.function.Consumer<java.util.Map.Entry<K,​V>>
      mapEntryBiConsumer​(java.util.function.BiConsumer<K,​V> consumer)
      Transform a BiConsumer to accept Map.Entry
      static <K,​V,​R>
      java.util.function.Function<java.util.Map.Entry<K,​V>,​R>
      mapEntryBiFunction​(java.util.function.BiFunction<K,​V,​R> mapper)
      Transform a BiFunction to operate over a Map.Entry
      static <T> java.util.function.Predicate<T> negate​(java.util.function.Predicate<T> p)
      Predicate negation as a static method which is more convenient than casting a lambda and calling Predicate.negate().
      static <T> java.util.function.BinaryOperator<T> throwingCombiner()
      A binary operator to be used with non-parallel Stream.reduce(Object, BiFunction, BinaryOperator) calls when a combiner is not needed.
      static <T,​R>
      java.util.function.Function<T,​R>
      wrapPartial​(java.util.function.Function<T,​R> partialFunction, java.util.function.Function<T,​R> ifNullFunction)
      Wrap a partial function (a function that can return null) with another function that replaces nulls.
      static <T> java.util.function.UnaryOperator<T> wrapPartialWithIdentity​(java.util.function.UnaryOperator<T> partialFunction)
      Transform partial function to a total function by falling back to identity when the input is not mapped.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Functional

        public Functional()
    • Method Detail

      • mapEntryBiFunction

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

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

        public static <T> java.util.function.UnaryOperator<T> wrapPartialWithIdentity​(java.util.function.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> java.util.function.Function<T,​R> wrapPartial​(java.util.function.Function<T,​R> partialFunction,
                                                                                     java.util.function.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> java.util.function.Function<A,​C> compose​(java.util.function.Function<? super B,​C> g,
                                                                                         java.util.function.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> java.util.function.Predicate<T> negate​(java.util.function.Predicate<T> p)
        Predicate negation as a static method which is more convenient than casting a lambda and calling Predicate.negate().
      • throwingCombiner

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