Class PredicateToolkit
- java.lang.Object
- 
- org.openjdk.jmc.common.util.PredicateToolkit
 
- 
- 
Constructor SummaryConstructors Constructor Description PredicateToolkit()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Predicate<T>and(Collection<Predicate<T>> predicates)Combine a collection of predicates using an AND operation.static <T,M extends Comparable<? super M>>
 Predicate<T>centerContained(IMemberAccessor<? extends IRange<M>,T> rangeAccessor, IRange<M> limit)Return a predicate based onlimitaccording toRangeMatchPolicy.CENTER_CONTAINED_IN_RIGHT_OPEN.static <T> Predicate<T>contains(IMemberAccessor<? extends String,T> valueAccessor, String substring)Create a predicate that checks if a string value contains a specified substring.static <T> Predicate<T>equals(IMemberAccessor<?,T> valueAccessor, Object item)Create a predicate that checks if a value is equal to a specified object.static <T> Predicate<T>falsePredicate()static PatterngetValidPattern(String regexp)Compile a regular expression into a pattern if possible.static <T> Predicate<T>is(T item)Create a predicate that checks if a value is a specified object.static booleanisFalseGuaranteed(Predicate<?> p)Test if a predicate is guaranteed to always test tofalse.static booleanisTrueGuaranteed(Predicate<?> p)Test if a predicate is guaranteed to always test totrue.static <T,M>
 Predicate<T>less(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit)Create a predicate that compares values to a limit.static <T,M>
 Predicate<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>
 Predicate<T>lessOrEqual(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit)Create a predicate that compares values to a limit.static <T> Predicate<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>
 Predicate<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>
 Predicate<T>more(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit)Create a predicate that compares values to a limit.static <T,M>
 Predicate<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>
 Predicate<T>moreOrEqual(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit)Create a predicate that compares values to a limit.static <T> Predicate<T>not(Predicate<T> predicate)Invert a predicate.static <T> Predicate<T>notEquals(IMemberAccessor<?,T> valueAccessor, Object item)Create a predicate that checks if a value is not equal to a specified object.static <T> Predicate<T>or(Collection<Predicate<T>> predicates)Combine a collection of predicates using an OR operation.static <T,M extends Comparable<? super M>>
 Predicate<T>rangeContained(IMemberAccessor<? extends IRange<M>,T> rangeAccessor, IRange<M> limit)Return a predicate based onlimitaccording toRangeMatchPolicy.CONTAINED_IN_CLOSED.static <T,M extends Comparable<? super M>>
 Predicate<T>rangeIntersects(IMemberAccessor<? extends IRange<M>,T> rangeAccessor, IRange<M> limit)Return a predicate based onlimitaccording toRangeMatchPolicy.CLOSED_INTERSECTS_WITH_CLOSED.static <T> Predicate<T>truePredicate()
 
- 
- 
- 
Method Detail- 
truePredicatepublic static <T> Predicate<T> truePredicate() - Returns:
- a predicate that always will test to true
 
 - 
falsePredicatepublic static <T> Predicate<T> falsePredicate() - Returns:
- a predicate that always will test to false
 
 - 
isTrueGuaranteedpublic static boolean isTrueGuaranteed(Predicate<?> p) Test if a predicate is guaranteed to always test totrue. Note that if this method returnsfalse, then it only means that it is unknown what the predicate will return.- Parameters:
- p- a predicate to test
- Returns:
- trueif the predicate is guaranteed to test to- true
 
 - 
isFalseGuaranteedpublic static boolean isFalseGuaranteed(Predicate<?> p) Test if a predicate is guaranteed to always test tofalse. Note that if this method returnsfalse, then it only means that it is unknown what the predicate will return.- Parameters:
- p- a predicate to test
- Returns:
- trueif the predicate is guaranteed to test to- false
 
 - 
andpublic static <T> Predicate<T> and(Collection<Predicate<T>> predicates) Combine a collection of predicates using an AND operation.- Parameters:
- predicates- input predicates
- Returns:
- a predicate that tests to trueif all input predicates test totrue
 
 - 
orpublic static <T> Predicate<T> or(Collection<Predicate<T>> predicates) Combine a collection of predicates using an OR operation.- Parameters:
- predicates- input predicates
- Returns:
- a predicate that tests to trueif at least one of the input predicates test totrue
 
 - 
notpublic static <T> Predicate<T> not(Predicate<T> predicate) Invert a predicate.- Parameters:
- predicate- predicate to invert
- Returns:
- a predicate that tests to trueif the input predicate tests tofalseand vice versa
 
 - 
lesspublic static <T,M> Predicate<T> less(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit, boolean orEqual) Create a predicate that compares values to a 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. - Type Parameters:
- T- type of objects passed into the predicate
- M- type of the value that is compared
- Parameters:
- valueAccessor- accessor used to get the value to check from the input type
- limit- value to compare against
- orEqual- if- true, test values that are equal to the limit to- true
- Returns:
- a predicate that tests to trueif the value to check is less than, or optionally equal to, the limit value
 
 - 
lesspublic static <T,M> Predicate<T> less(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit) Create a predicate that compares values to a 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. - Type Parameters:
- T- type of objects passed into the predicate
- M- type of the value that is compared
- Parameters:
- valueAccessor- accessor used to get the value to check from the input type
- limit- value to compare against
- Returns:
- a predicate that tests to trueif the value to check is strictly less than the limit value
 
 - 
lessOrEqualpublic static <T,M> Predicate<T> lessOrEqual(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit) Create a predicate that compares values to a 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. - Type Parameters:
- T- type of objects passed into the predicate
- M- type of the value that is compared
- Parameters:
- valueAccessor- accessor used to get the value to check from the input type
- limit- value to compare against
- Returns:
- a predicate that tests to trueif the value to check is less than or equal to the limit value
 
 - 
morepublic static <T,M> Predicate<T> more(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit, boolean orEqual) Create a predicate that compares values to a 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. - Type Parameters:
- T- type of objects passed into the predicate
- M- type of the value that is compared
- Parameters:
- valueAccessor- accessor used to get the value to check from the input type
- limit- value to compare against
- orEqual- if- true, test values that are equal to the limit to- true
- Returns:
- a predicate that tests to trueif the value to check is greater than, or optionally equal to, the limit value
 
 - 
morepublic static <T,M> Predicate<T> more(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit) Create a predicate that compares values to a 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. - Type Parameters:
- T- type of objects passed into the predicate
- M- type of the value that is compared
- Parameters:
- valueAccessor- accessor used to get the value to check from the input type
- limit- value to compare against
- Returns:
- a predicate that tests to trueif the value to check is strictly greater than the limit value
 
 - 
moreOrEqualpublic static <T,M> Predicate<T> moreOrEqual(IMemberAccessor<? extends M,T> valueAccessor, Comparable<? super M> limit) Create a predicate that compares values to a 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. - Type Parameters:
- T- type of objects passed into the predicate
- M- type of the value that is compared
- Parameters:
- valueAccessor- accessor used to get the value to check from the input type
- limit- value to compare against
- Returns:
- a predicate that tests to trueif the value to check is greater than or equal to the limit value
 
 - 
rangeIntersectspublic static <T,M extends Comparable<? super M>> Predicate<T> rangeIntersects(IMemberAccessor<? extends IRange<M>,T> rangeAccessor, IRange<M> limit) Return a predicate based onlimitaccording toRangeMatchPolicy.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. - Type Parameters:
- T- type of objects passed into the predicate
- M- type of the range value that is compared
- Parameters:
- rangeAccessor- accessor used to get the range value to check from the input type
- limit- range value to compare against
- Returns:
- a predicate that tests to trueif the range value to check intersects with the limit range
 
 - 
rangeContainedpublic static <T,M extends Comparable<? super M>> Predicate<T> rangeContained(IMemberAccessor<? extends IRange<M>,T> rangeAccessor, IRange<M> limit) Return a predicate based onlimitaccording toRangeMatchPolicy.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. - Type Parameters:
- T- type of objects passed into the predicate
- M- type of the range value that is compared
- Parameters:
- rangeAccessor- accessor used to get the range value to check from the input type
- limit- range value to compare against
- Returns:
- a predicate that tests to trueif the range value to check is contained in the limit range
 
 - 
centerContainedpublic static <T,M extends Comparable<? super M>> Predicate<T> centerContained(IMemberAccessor<? extends IRange<M>,T> rangeAccessor, IRange<M> limit) Return a predicate based onlimitaccording toRangeMatchPolicy.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. - Type Parameters:
- T- type of objects passed into the predicate
- M- type of the range value that is compared
- Parameters:
- rangeAccessor- accessor used to get the range value to check from the input type
- limit- range value to compare against
- Returns:
- a predicate that tests to trueif the center point of the range value to check is contained in the limit range
 
 - 
equalspublic static <T> Predicate<T> equals(IMemberAccessor<?,T> valueAccessor, Object item) Create a predicate that checks if a value is equal to a specified object.The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor. - Type Parameters:
- T- type of objects passed into the predicate
- Parameters:
- valueAccessor- accessor used to get the value to check from the input type
- item- object to compare against
- Returns:
- a predicate that tests to trueif the value to check is equal to the specified object
 
 - 
notEqualspublic static <T> Predicate<T> notEquals(IMemberAccessor<?,T> valueAccessor, Object item) Create a predicate that checks if a value is not equal to a specified object.The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor. - Type Parameters:
- T- type of objects passed into the predicate
- Parameters:
- valueAccessor- accessor used to get the value to check from the input type
- item- object to compare against
- Returns:
- a predicate that tests to trueif the value to check is not equal to the specified object
 
 - 
ispublic static <T> Predicate<T> is(T item) Create a predicate that checks if a value is a specified object. This check is performed using object identity.The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor. - Type Parameters:
- T- type of objects passed into the predicate
- Parameters:
- item- object to compare against
- Returns:
- a predicate that tests to trueif the value to check is the specified object
 
 - 
memberOfpublic static <T,M> Predicate<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.The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor. - Type Parameters:
- T- type of objects passed into the predicate
- M- type of the range value that is compared
- Parameters:
- valueAccessor- accessor used to get the value to check from the input type
- items- set of objects to compare against
- Returns:
- a predicate that tests to trueif the object to check is included in the specified set
 
 - 
matchespublic static <T> Predicate<T> matches(IMemberAccessor<? extends String,T> valueAccessor, String regexp) Create a predicate that checks if a string value matches a regular expression.The predicate takes an input object as argument but the value that is checked is extracted from the input object using a member accessor. - Type Parameters:
- T- type of objects passed into the predicate
- Parameters:
- valueAccessor- string accessor used to get the value to check from the input type
- regexp- the regular expression to match
- Returns:
- a predicate that tests to trueif the string value matches the regular expression
 
 - 
containspublic static <T> Predicate<T> contains(IMemberAccessor<? extends String,T> valueAccessor, String substring) Create a predicate that checks if a string value contains a specified 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. - Parameters:
- valueAccessor- string accessor used to get the value to check from the input type
- substring- the substring to look for
- Returns:
- a predicate that tests to trueif the string value contains the substring
 
 - 
getValidPatternpublic static Pattern getValidPattern(String regexp) Compile a regular expression into a pattern if possible. If the expression can't be compiled, return a valid pattern that will give 0 matches (at least for single lines).- Parameters:
- regexp- regular expression to compile
- Returns:
- a valid regular expression pattern instance
 
 
- 
 
-