Package com.complexible.common.base
Class Functional
- java.lang.Object
-
- com.complexible.common.base.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 callingFunction.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 acceptMap.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 aMap.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 callingPredicate.negate()
.static <T> java.util.function.BinaryOperator<T>
throwingCombiner()
A binary operator to be used with non-parallelStream.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.
-
-
-
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 aMap.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 acceptMap.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 callingFunction.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 callingPredicate.negate()
.
-
throwingCombiner
public static <T> java.util.function.BinaryOperator<T> throwingCombiner()
A binary operator to be used with non-parallelStream.reduce(Object, BiFunction, BinaryOperator)
calls when a combiner is not needed.
-
-