A collection of static factory methods providing commonly useful implementations of operations.
Constructor and description |
---|
private CommonOps
() |
Type | Name and description |
---|---|
static Predicate<T> |
andPredicate(Predicate<S> first, Predicate<? super T> second) Returns a predicate evaluating to the conjunction of its contained predicates. |
static DoublePredicate |
andPredicate(DoublePredicate first, DoublePredicate second) Returns a predicate evaluating to the conjunction of its contained predicates. |
static LongPredicate |
andPredicate(LongPredicate first, LongPredicate second) Returns a predicate evaluating to the conjunction of its contained predicates. |
static java.util.Comparator<java.lang.Object> |
castedComparator() Returns a Comparator that casts its arguments as Comparable on each comparison, throwing ClassCastException on failure. |
static Reducer<java.lang.Object> |
castedMaxReducer() Returns a reducer returning maximum of two values, or null if both arguments are null, and that casts
its arguments as Comparable on each comparison, throwing
ClassCastException on failure. |
static Reducer<java.lang.Object> |
castedMinReducer() Returns a reducer returning minimum of two values, or null if both arguments are null, and that casts
its arguments as Comparable on each comparison, throwing
ClassCastException on failure. |
static Op<T, V> |
compoundOp(Op<? super T, ? extends U> first, Op<? super U, ? extends V> second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static Op<T, V> |
compoundOp(ObjectToDouble<? super T> first, DoubleToObject<? extends V> second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static Op<T, V> |
compoundOp(ObjectToLong<? super T> first, LongToObject<? extends V> second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static DoubleToObject<V> |
compoundOp(DoubleToObject<? extends T> first, Op<? super T, ? extends V> second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static LongToObject<V> |
compoundOp(LongToObject<? extends T> first, Op<? super T, ? extends V> second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static ObjectToDouble<T> |
compoundOp(Op<? super T, ? extends U> first, ObjectToDouble<? super U> second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static ObjectToLong<T> |
compoundOp(Op<? super T, ? extends U> first, ObjectToLong<? super U> second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static ObjectToDouble<T> |
compoundOp(ObjectToDouble<? super T> first, DoubleOp second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static ObjectToLong<T> |
compoundOp(ObjectToDouble<? super T> first, DoubleToLong second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static ObjectToLong<T> |
compoundOp(ObjectToLong<? super T> first, LongOp second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static ObjectToDouble<T> |
compoundOp(ObjectToLong<? super T> first, LongToDouble second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static DoubleOp |
compoundOp(DoubleOp first, DoubleOp second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static DoubleToLong |
compoundOp(DoubleOp first, DoubleToLong second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static DoubleToLong |
compoundOp(DoubleToLong first, LongOp second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static DoubleToObject<T> |
compoundOp(DoubleToLong first, LongToObject<? extends T> second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static LongToObject<T> |
compoundOp(LongToDouble first, DoubleToObject<? extends T> second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static LongToDouble |
compoundOp(LongOp first, LongToDouble second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static LongToDouble |
compoundOp(LongToDouble first, DoubleOp second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static DoubleToObject<T> |
compoundOp(DoubleOp first, DoubleToObject<? extends T> second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static LongToObject<T> |
compoundOp(LongOp first, LongToObject<? extends T> second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static DoubleOp |
compoundOp(DoubleToObject<? extends T> first, ObjectToDouble<? super T> second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static LongToDouble |
compoundOp(LongToObject<? extends T> first, ObjectToDouble<? super T> second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static DoubleToLong |
compoundOp(DoubleToObject<? extends T> first, ObjectToLong<? super T> second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static LongOp |
compoundOp(LongToObject<? extends T> first, ObjectToLong<? super T> second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static LongOp |
compoundOp(LongOp first, LongOp second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static DoubleOp |
compoundOp(DoubleToLong first, LongToDouble second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static LongOp |
compoundOp(LongToDouble first, DoubleToLong second) Returns a composite mapper that applies a second mapper to the results of applying the first one. |
static DoubleReducer |
doubleAdder() Returns a reducer that adds two double elements. |
static BinaryDoublePredicate |
doubleEqualityPredicate() Returns a predicate evaluating to true if the first argument == the second. |
static BinaryDoublePredicate |
doubleInequalityPredicate() Returns a predicate evaluating to true if the first argument {@code ! |
static DoubleReducer |
doubleMaxReducer(DoubleComparator comparator) Returns a reducer returning the maximum of two double elements, using the given comparator. |
static DoubleReducer |
doubleMinReducer(DoubleComparator comparator) Returns a reducer returning the minimum of two double elements, using the given comparator. |
static DoubleGenerator |
doubleRandom() Returns a generator producing uniform random values between zero and one, with the same properties as java.util.Random#nextDouble. |
static DoubleGenerator |
doubleRandom(double bound) Returns a generator producing uniform random values between zero and the given bound, with the same properties as java.util.Random#nextDouble. |
static DoubleGenerator |
doubleRandom(double least, double bound) Returns a generator producing uniform random values between the given least value (inclusive) and bound (exclusive). |
static BinaryPredicate<java.lang.Object, java.lang.Object> |
equalityPredicate() Returns a predicate evaluating to true if the first argument equals the second. |
static BinaryPredicate<java.lang.Object, java.lang.Object> |
identityPredicate() Returns a predicate evaluating to true if the first argument == the second. |
static BinaryPredicate<java.lang.Object, java.lang.Object> |
inequalityPredicate() Returns a predicate evaluating to true if the first argument {@code ! |
static Predicate<java.lang.Object> |
instanceofPredicate(java.lang.Class type) Returns a predicate evaluating to true if its argument is an instance of (see java.lang.Class#isInstance the given type (class). |
static IntReducer |
intAdder() Returns a reducer that adds two int elements. |
static BinaryIntPredicate |
intEqualityPredicate() Returns a predicate evaluating to true if the first argument == the second. |
static BinaryIntPredicate |
intInequalityPredicate() Returns a predicate evaluating to true if the first argument {@code ! |
static IntGenerator |
intRandom() Returns a generator producing uniform random values with the same properties as java.util.Random#nextInt. |
static IntGenerator |
intRandom(int bound) Returns a generator producing uniform random values with the same properties as java.util.Random#nextInt(int). |
static IntGenerator |
intRandom(int least, int bound) Returns a generator producing uniform random values between the given least value (inclusive) and bound (exclusive). |
static Predicate<java.lang.Object> |
isAssignablePredicate(java.lang.Class type) Returns a predicate evaluating to true if its argument is assignable from (see java.lang.Class#isAssignableFrom the given type (class). |
static Predicate<java.lang.Object> |
isNonNullPredicate() Returns a predicate evaluating to true if its argument is non-null. |
static Predicate<java.lang.Object> |
isNullPredicate() Returns a predicate evaluating to true if its argument is null. |
static LongReducer |
longAdder() Returns a reducer that adds two long elements. |
static BinaryLongPredicate |
longEqualityPredicate() Returns a predicate evaluating to true if the first argument == the second. |
static BinaryLongPredicate |
longInequalityPredicate() Returns a predicate evaluating to true if the first argument == the second. |
static LongReducer |
longMaxReducer(LongComparator comparator) Returns a reducer returning the maximum of two long elements, using the given comparator. |
static LongReducer |
longMinReducer(LongComparator comparator) Returns a reducer returning the minimum of two long elements, using the given comparator. |
static LongGenerator |
longRandom() Returns a generator producing uniform random values with the same properties as java.util.Random#nextLong. |
static LongGenerator |
longRandom(long bound) Returns a generator producing uniform random values with the same properties as java.util.Random#nextInt(int). |
static LongGenerator |
longRandom(long least, long bound) Returns a generator producing uniform random values between the given least value (inclusive) and bound (exclusive). |
static Reducer<T> |
maxReducer(java.util.Comparator<? super T> comparator) Returns a reducer returning the maximum of two elements, using the given comparator, and treating null as less than any non-null element. |
static Reducer<T> |
minReducer(java.util.Comparator<? super T> comparator) Returns a reducer returning the minimum of two elements, using the given comparator, and treating null as greater than any non-null element. |
static java.util.Comparator<T> |
naturalComparator(java.lang.Class<T> type) Returns a Comparator for Comparable objects. |
static DoubleComparator |
naturalDoubleComparator() Returns a comparator for doubles relying on natural ordering. |
static DoubleReducer |
naturalDoubleMaxReducer() Returns a reducer returning the maximum of two double elements, using natural comparator. |
static DoubleReducer |
naturalDoubleMinReducer() Returns a reducer returning the minimum of two double elements, using natural comparator. |
static LongComparator |
naturalLongComparator() Returns a comparator for longs relying on natural ordering. |
static LongReducer |
naturalLongMaxReducer() Returns a reducer returning the maximum of two long elements, using natural comparator. |
static LongReducer |
naturalLongMinReducer() A reducer returning the minimum of two long elements, using natural comparator. |
static Reducer<T> |
naturalMaxReducer(java.lang.Class<T> type) Returns a reducer returning the maximum of two Comparable elements, treating null as less than any non-null element. |
static Reducer<T> |
naturalMinReducer(java.lang.Class<T> type) Returns a reducer returning the minimum of two Comparable elements, treating null as greater than any non-null element. |
static BinaryPredicate<java.lang.Object, java.lang.Object> |
nonidentityPredicate() Returns a predicate evaluating to true if the first argument {@code ! |
static Predicate<T> |
notPredicate(Predicate<T> pred) Returns a predicate evaluating to the negation of its contained predicate. |
static DoublePredicate |
notPredicate(DoublePredicate pred) Returns a predicate evaluating to the negation of its contained predicate. |
static LongPredicate |
notPredicate(LongPredicate pred) Returns a predicate evaluating to the negation of its contained predicate. |
static Predicate<T> |
orPredicate(Predicate<S> first, Predicate<? super T> second) Returns a predicate evaluating to the disjunction of its contained predicates. |
static DoublePredicate |
orPredicate(DoublePredicate first, DoublePredicate second) Returns a predicate evaluating to the disjunction of its contained predicates. |
static LongPredicate |
orPredicate(LongPredicate first, LongPredicate second) Returns a predicate evaluating to the disjunction of its contained predicates. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Returns a predicate evaluating to the conjunction of its contained predicates.
Returns a predicate evaluating to the conjunction of its contained predicates.
Returns a predicate evaluating to the conjunction of its contained predicates.
Returns a Comparator that casts its arguments as Comparable on each comparison, throwing ClassCastException on failure.
Returns a reducer returning maximum of two values, or
null
if both arguments are null, and that casts
its arguments as Comparable on each comparison, throwing
ClassCastException on failure.
Returns a reducer returning minimum of two values, or
null
if both arguments are null, and that casts
its arguments as Comparable on each comparison, throwing
ClassCastException on failure.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a composite mapper that applies a second mapper to the results of applying the first one.
Returns a reducer that adds two double elements.
Returns a predicate evaluating to true if the
first argument ==
the second.
Returns a predicate evaluating to true if the
first argument !=
the second.
Returns a reducer returning the maximum of two double elements, using the given comparator.
Returns a reducer returning the minimum of two double elements, using the given comparator.
Returns a generator producing uniform random values between zero and one, with the same properties as java.util.Random#nextDouble.
Returns a generator producing uniform random values between zero and the given bound, with the same properties as java.util.Random#nextDouble.
bound
- the upper bound (exclusive) of opd valuesReturns a generator producing uniform random values between the given least value (inclusive) and bound (exclusive).
least
- the least value returnedbound
- the upper bound (exclusive) of opd values Returns a predicate evaluating to true if the
first argument equals
the second.
Returns a predicate evaluating to true if the
first argument ==
the second.
Returns a predicate evaluating to true if the
first argument !equals
the second.
Returns a predicate evaluating to true if its argument is an instance of (see java.lang.Class#isInstance the given type (class).
Returns a reducer that adds two int elements.
Returns a predicate evaluating to true if the
first argument ==
the second.
Returns a predicate evaluating to true if the
first argument !=
the second.
Returns a generator producing uniform random values with the same properties as java.util.Random#nextInt.
Returns a generator producing uniform random values with the same properties as java.util.Random#nextInt(int).
bound
- the upper bound (exclusive) of opd valuesReturns a generator producing uniform random values between the given least value (inclusive) and bound (exclusive).
least
- the least value returnedbound
- the upper bound (exclusive) of opd valuesReturns a predicate evaluating to true if its argument is assignable from (see java.lang.Class#isAssignableFrom the given type (class).
Returns a predicate evaluating to true if its argument is non-null.
Returns a predicate evaluating to true if its argument is null.
Returns a reducer that adds two long elements.
Returns a predicate evaluating to true if the
first argument ==
the second.
Returns a predicate evaluating to true if the
first argument ==
the second.
Returns a reducer returning the maximum of two long elements, using the given comparator.
Returns a reducer returning the minimum of two long elements, using the given comparator.
Returns a generator producing uniform random values with the same properties as java.util.Random#nextLong.
Returns a generator producing uniform random values with the same properties as java.util.Random#nextInt(int).
bound
- the upper bound (exclusive) of opd valuesReturns a generator producing uniform random values between the given least value (inclusive) and bound (exclusive).
least
- the least value returnedbound
- the upper bound (exclusive) of opd valuesReturns a reducer returning the maximum of two elements, using the given comparator, and treating null as less than any non-null element.
Returns a reducer returning the minimum of two elements, using the given comparator, and treating null as greater than any non-null element.
Returns a Comparator for Comparable objects.
Returns a comparator for doubles relying on natural ordering.
Returns a reducer returning the maximum of two double elements, using natural comparator.
Returns a reducer returning the minimum of two double elements, using natural comparator.
Returns a comparator for longs relying on natural ordering.
Returns a reducer returning the maximum of two long elements, using natural comparator.
A reducer returning the minimum of two long elements, using natural comparator.
Returns a reducer returning the maximum of two Comparable elements, treating null as less than any non-null element.
Returns a reducer returning the minimum of two Comparable elements, treating null as greater than any non-null element.
Returns a predicate evaluating to true if the
first argument !=
the second.
Returns a predicate evaluating to the negation of its contained predicate.
Returns a predicate evaluating to the negation of its contained predicate.
Returns a predicate evaluating to the negation of its contained predicate.
Returns a predicate evaluating to the disjunction of its contained predicates.
Returns a predicate evaluating to the disjunction of its contained predicates.
Returns a predicate evaluating to the disjunction of its contained predicates.
Copyright © 2008–2014 Václav Pech. All Rights Reserved.