public class PredicateToolkit extends Object
IPredicate matching various criteria.| Constructor and Description |
|---|
PredicateToolkit() |
| Modifier and Type | Method and Description |
|---|---|
static <T> IPredicate<T> |
and(Collection<IPredicate<T>> predicates)
Combine a collection of predicates using an AND operation.
|
static <T,M extends Comparable<? super M>> |
centerContained(IMemberAccessor<? extends IRange<M>,T> rangeAccessor,
IRange<M> limit)
Return a predicate based on
limit according to
RangeMatchPolicy.CENTER_CONTAINED_IN_RIGHT_OPEN. |
static <T> IPredicate<T> |
contains(IMemberAccessor<? extends String,T> valueAccessor,
String substring)
Create a predicate that checks if a string value contains a specified substring.
|
static <T> IPredicate<T> |
equals(IMemberAccessor<?,T> valueAccessor,
Object item)
Create a predicate that checks if a value is equal to a specified object.
|
static <T> IPredicate<T> |
falsePredicate() |
static Pattern |
getValidPattern(String regexp)
Compile a regular expression into a pattern if possible.
|
static <T> IPredicate<T> |
is(T item)
Create a predicate that checks if a value is a specified object.
|
static boolean |
isFalseGuaranteed(IPredicate<?> p)
Test if a predicate is guaranteed to always evaluate to
false. |
static boolean |
isTrueGuaranteed(IPredicate<?> p)
Test if a predicate is guaranteed to always evaluate to
true. |
static <T,M> IPredicate<T> |
less(IMemberAccessor<? extends M,T> valueAccessor,
Comparable<? super M> limit)
Create a predicate that compares values to a limit.
|
static <T,M> IPredicate<T> |
less(IMemberAccessor<? extends M,T> valueAccessor,
Comparable<? super M> limit,
boolean orEqual)
Create a predicate that compares values to a limit.
|
static <T,M> IPredicate<T> |
lessOrEqual(IMemberAccessor<? extends M,T> valueAccessor,
Comparable<? super M> limit)
Create a predicate that compares values to a limit.
|
static <T> IPredicate<T> |
matches(IMemberAccessor<? extends String,T> valueAccessor,
String regexp)
Create a predicate that checks if a string value matches a regular expression.
|
static <T,M> IPredicate<T> |
memberOf(IMemberAccessor<? extends M,T> valueAccessor,
Set<? extends M> items)
Create a predicate that checks if a value is included in a specified set.
|
static <T,M> IPredicate<T> |
more(IMemberAccessor<? extends M,T> valueAccessor,
Comparable<? super M> limit)
Create a predicate that compares values to a limit.
|
static <T,M> IPredicate<T> |
more(IMemberAccessor<? extends M,T> valueAccessor,
Comparable<? super M> limit,
boolean orEqual)
Create a predicate that compares values to a limit.
|
static <T,M> IPredicate<T> |
moreOrEqual(IMemberAccessor<? extends M,T> valueAccessor,
Comparable<? super M> limit)
Create a predicate that compares values to a limit.
|
static <T> IPredicate<T> |
not(IPredicate<T> predicate)
Invert a predicate.
|
static <T> IPredicate<T> |
notEquals(IMemberAccessor<?,T> valueAccessor,
Object item)
Create a predicate that checks if a value is not equal to a specified object.
|
static <T> IPredicate<T> |
or(Collection<IPredicate<T>> predicates)
Combine a collection of predicates using an OR operation.
|
static <T,M extends Comparable<? super M>> |
rangeContained(IMemberAccessor<? extends IRange<M>,T> rangeAccessor,
IRange<M> limit)
Return a predicate based on
limit according to
RangeMatchPolicy.CONTAINED_IN_CLOSED. |
static <T,M extends Comparable<? super M>> |
rangeIntersects(IMemberAccessor<? extends IRange<M>,T> rangeAccessor,
IRange<M> limit)
Return a predicate based on
limit according to
RangeMatchPolicy.CLOSED_INTERSECTS_WITH_CLOSED. |
static <T> IPredicate<T> |
truePredicate() |
public static <T> IPredicate<T> truePredicate()
truepublic static <T> IPredicate<T> falsePredicate()
falsepublic static boolean isTrueGuaranteed(IPredicate<?> p)
true. Note that if this
method returns false, then it only means that it is unknown what the predicate will
return.p - a predicate to testtrue if the predicate is guaranteed to evaluate to truepublic static boolean isFalseGuaranteed(IPredicate<?> p)
false. Note that if this
method returns false, then it only means that it is unknown what the predicate will
return.p - a predicate to testtrue if the predicate is guaranteed to evaluate to falsepublic static <T> IPredicate<T> and(Collection<IPredicate<T>> predicates)
predicates - input predicatestrue if all input predicates evaluate to
truepublic static <T> IPredicate<T> or(Collection<IPredicate<T>> predicates)
predicates - input predicatestrue if at least one of the input predicates
evaluate to truepublic static <T> IPredicate<T> not(IPredicate<T> predicate)
predicate - predicate to inverttrue if the input predicate evaluates to
false and vice versapublic static <T,M> IPredicate<T> less(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit, boolean orEqual)
The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor.
T - type of objects passed into the predicateM - type of the value that is comparedvalueAccessor - accessor used to get the value to check from the input typelimit - value to compare againstorEqual - if true, evaluate values that are equal to the limit to truetrue if the value to check is less than, or
optionally equal to, the limit valuepublic static <T,M> IPredicate<T> less(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit)
The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor.
T - type of objects passed into the predicateM - type of the value that is comparedvalueAccessor - accessor used to get the value to check from the input typelimit - value to compare againsttrue if the value to check is strictly less
than the limit valuepublic static <T,M> IPredicate<T> lessOrEqual(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit)
The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor.
T - type of objects passed into the predicateM - type of the value that is comparedvalueAccessor - accessor used to get the value to check from the input typelimit - value to compare againsttrue if the value to check is less than or
equal to the limit valuepublic static <T,M> IPredicate<T> more(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit, boolean orEqual)
The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor.
T - type of objects passed into the predicateM - type of the value that is comparedvalueAccessor - accessor used to get the value to check from the input typelimit - value to compare againstorEqual - if true, evaluate values that are equal to the limit to truetrue if the value to check is greater than, or
optionally equal to, the limit valuepublic static <T,M> IPredicate<T> more(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit)
The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor.
T - type of objects passed into the predicateM - type of the value that is comparedvalueAccessor - accessor used to get the value to check from the input typelimit - value to compare againsttrue if the value to check is strictly greater
than the limit valuepublic static <T,M> IPredicate<T> moreOrEqual(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit)
The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor.
T - type of objects passed into the predicateM - type of the value that is comparedvalueAccessor - accessor used to get the value to check from the input typelimit - value to compare againsttrue if the value to check is greater than or
equal to the limit valuepublic static <T,M extends Comparable<? super M>> IPredicate<T> rangeIntersects(IMemberAccessor<? extends IRange<M>,T> rangeAccessor, IRange<M> limit)
limit according to
RangeMatchPolicy.CLOSED_INTERSECTS_WITH_CLOSED.
The predicate takes an input object as argument but the range that is checked is extracted from the input object using a member accessor.
T - type of objects passed into the predicateM - type of the range value that is comparedrangeAccessor - accessor used to get the range value to check from the input typelimit - range value to compare againsttrue if the range value to check intersects
with the limit rangepublic static <T,M extends Comparable<? super M>> IPredicate<T> rangeContained(IMemberAccessor<? extends IRange<M>,T> rangeAccessor, IRange<M> limit)
limit according to
RangeMatchPolicy.CONTAINED_IN_CLOSED.
The predicate takes an input object as argument but the range that is checked is extracted from the input object using a member accessor.
T - type of objects passed into the predicateM - type of the range value that is comparedrangeAccessor - accessor used to get the range value to check from the input typelimit - range value to compare againsttrue if the range value to check is contained
in the limit rangepublic static <T,M extends Comparable<? super M>> IPredicate<T> centerContained(IMemberAccessor<? extends IRange<M>,T> rangeAccessor, IRange<M> limit)
limit according to
RangeMatchPolicy.CENTER_CONTAINED_IN_RIGHT_OPEN.
The predicate takes an input object as argument but the range that is checked is extracted from the input object using a member accessor.
T - type of objects passed into the predicateM - type of the range value that is comparedrangeAccessor - accessor used to get the range value to check from the input typelimit - range value to compare againsttrue if the center point of the range value to
check is contained in the limit rangepublic static <T> IPredicate<T> equals(IMemberAccessor<?,T> valueAccessor, Object item)
The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor.
T - type of objects passed into the predicatevalueAccessor - accessor used to get the value to check from the input typeitem - object to compare againsttrue if the value to check is equal to the
specified objectpublic static <T> IPredicate<T> notEquals(IMemberAccessor<?,T> valueAccessor, Object item)
The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor.
T - type of objects passed into the predicatevalueAccessor - accessor used to get the value to check from the input typeitem - object to compare againsttrue if the value to check is not equal to the
specified objectpublic static <T> IPredicate<T> is(T item)
The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor.
T - type of objects passed into the predicateitem - object to compare againsttrue if the value to check is the specified
objectpublic static <T,M> IPredicate<T> memberOf(IMemberAccessor<? extends M,T> valueAccessor, Set<? extends M> items)
The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor.
T - type of objects passed into the predicateM - type of the range value that is comparedvalueAccessor - accessor used to get the value to check from the input typeitems - set of objects to compare againsttrue if the object to check is included in the
specified setpublic static <T> IPredicate<T> matches(IMemberAccessor<? extends String,T> valueAccessor, String regexp)
The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor.
T - type of objects passed into the predicatevalueAccessor - string accessor used to get the value to check from the input typeregexp - the regular expression to matchtrue if the string value matches the regular
expressionpublic static <T> IPredicate<T> contains(IMemberAccessor<? extends String,T> valueAccessor, String substring)
The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor.
valueAccessor - string accessor used to get the value to check from the input typesubstring - the substring to look fortrue if the string value contains the substringpublic static Pattern getValidPattern(String regexp)
regexp - regular expression to compileCopyright © 2019. All rights reserved.