Package one.microstream.functional
Class XFunc
java.lang.Object
one.microstream.functional.XFunc
public final class XFunc extends Object
Normally, writing "Func" instead of "Functional" is a capital sin of writing clean code.
However, in the sake of shortness for static util method class names AND in light of
"Mathematics", "Sorting" and "Characters" already being shortened to the (albeit more common)
names "Math", "Sort", "Chars" PLUS the unique recognizability of "Func", the shortness trumped
the clarity of completeness here (as well).
Rules are made for people and must be bendable if reasonable reflection (not laziness!)
concludes necessity.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
XFunc.MaxInteger
-
Method Summary
Modifier and Type Method Description static <E, R> Aggregator<E,R>
aggregator(BiConsumer<? super E,? super R> joiner, R aggregate)
static <T> Predicate<T>
all()
Functional alias forreturn true;
.static <T> Predicate<T>
all(Predicate<? super T>... predicates)
static <T> Predicate<T>
any()
Functional alias forreturn true;
.static <E> AggregateCount<E>
count()
static <E> Aggregator<E,Long>
counter()
static <E> Predicate<E>
isEqual(E sample, Equalator<? super E> equalator)
static <T> Predicate<T>
isEqualTo(T subject)
static Predicate<Object>
isInstanceOf(Class<?> type)
static Predicate<Object>
isInstanceOf(Class<?>... types)
static <T> Predicate<T>
isSameAs(T subject)
static Aggregator<Integer,Integer>
max(int initialValue)
static <T> Predicate<T>
none()
Functional alias forreturn false;
.static <E> void
noOp(E e)
Literally a no-opConsumer
.static <T> Predicate<T>
not(Predicate<T> predicate)
Fluent alias forpredicate.negate()
.static Predicate<Object>
notIsInstanceOf(Class<?> type)
static Predicate<Object>
notIsInstanceOf(Class<?>... types)
static <T> Predicate<T>
notNull()
Functional alias forreturn e != null;
.static <T> Predicate<T>
one(Predicate<? super T>... predicates)
static <T> Function<T,T>
passThrough()
static <T, E extends T>
Predicate<T>predicate(E subject, Equalator<T> equalator)
static <T> Predicate<T>
select(Predicate<T> predicate)
Required to use lambdas or method reference in conjunction withPredicate.and(Predicate)
etc.static <T, R> Function<T,R>
toNull()
static <T extends S, S>
Function<T,S>upcast()
Pass-through function with type upcast.static <I, O> Consumer<I>
wrapWithFunction(Consumer<? super O> target, Function<? super I,O> function)
static <I, O> Consumer<I>
wrapWithFunctionLimit(Consumer<? super O> target, Function<? super I,O> function, long limit)
static <I, O> Consumer<I>
wrapWithFunctionSkip(Consumer<? super O> target, Function<? super I,O> function, long skip)
static <I, O> Consumer<I>
wrapWithFunctionSkipLimit(Consumer<? super O> target, Function<? super I,O> function, long skip, long limit)
static <E> Consumer<E>
wrapWithLimit(Consumer<? super E> target, long limit)
static <E> Consumer<E>
wrapWithPredicate(Consumer<? super E> target, Predicate<? super E> predicate)
static <I, O> Consumer<I>
wrapWithPredicateFunction(Consumer<? super O> target, Predicate<? super I> predicate, Function<? super I,O> function)
static <I, O> Consumer<I>
wrapWithPredicateFunctionLimit(Consumer<? super O> target, Predicate<? super I> predicate, Function<? super I,O> function, long limit)
static <I, O> Consumer<I>
wrapWithPredicateFunctionSkip(Consumer<? super O> target, Predicate<? super I> predicate, Function<? super I,O> function, long skip)
static <I, O> Consumer<I>
wrapWithPredicateFunctionSkipLimit(Consumer<? super O> target, Predicate<? super I> predicate, Function<? super I,O> function, long skip, long limit)
static <E> Consumer<E>
wrapWithPredicateLimit(Consumer<? super E> target, Predicate<? super E> predicate, long limit)
static <E> Consumer<E>
wrapWithPredicateSkip(Consumer<? super E> target, Predicate<? super E> predicate, long skip)
static <E> Consumer<E>
wrapWithPredicateSkipLimit(Consumer<? super E> target, Predicate<? super E> predicate, long skip, long limit)
static <E> Consumer<E>
wrapWithSkip(Consumer<? super E> target, long skip)
static <E> Consumer<E>
wrapWithSkipLimit(Consumer<? super E> target, long skip, long limit)
-
Method Details
-
all
Functional alias forreturn true;
. -
any
Functional alias forreturn true;
. -
none
Functional alias forreturn false;
. -
notNull
Functional alias forreturn e != null;
. -
toNull
-
passThrough
-
noOp
public static <E> void noOp(E e)Literally a no-opConsumer
. -
all
-
select
Required to use lambdas or method reference in conjunction withPredicate.and(Predicate)
etc.- Parameters:
predicate
- a predicate instance- Returns:
- the passed predicate instance without execution any further logic.
-
one
-
isEqual
-
isEqualTo
-
isSameAs
-
predicate
-
isInstanceOf
-
notIsInstanceOf
-
isInstanceOf
-
notIsInstanceOf
-
not
Fluent alias forpredicate.negate()
. -
max
-
count
-
aggregator
public static final <E, R> Aggregator<E,R> aggregator(BiConsumer<? super E,? super R> joiner, R aggregate) -
counter
-
wrapWithSkip
-
wrapWithLimit
-
wrapWithSkipLimit
-
wrapWithPredicate
-
wrapWithPredicateSkip
-
wrapWithPredicateLimit
-
wrapWithPredicateSkipLimit
-
wrapWithFunction
-
wrapWithFunctionSkip
-
wrapWithFunctionLimit
-
wrapWithFunctionSkipLimit
-
wrapWithPredicateFunction
-
wrapWithPredicateFunctionSkip
-
wrapWithPredicateFunctionLimit
-
wrapWithPredicateFunctionSkipLimit
-
upcast
Pass-through function with type upcast. Can sometimes be required to correctly handle nested types.Consider the following example with V1 extends V: (e.g. V is an interface and V1 is an implementation of V)
XMap<K, V1> workingCollection = ... ; XImmutableMap<K, V> finalCollection = ConstHashTable.NewProjected(input, <K>passthrough(), <V1, V>upcast());
-