Package com.jayway.jsonpath
Class Criteria
- java.lang.Object
-
- com.jayway.jsonpath.Criteria
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.jayway.jsonpath.Predicate
Predicate.PredicateContext
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Criteriaall(java.lang.Object... o)Thealloperator is similar to $in, but instead of matching any value in the specified array all values in the array must be matched.Criteriaall(java.util.Collection<?> c)Thealloperator is similar to $in, but instead of matching any value in the specified array all values in the array must be matched.Criteriaand(java.lang.String key)Static factory method to create a Criteria using the provided keyCriteriaanyof(java.lang.Object... o)Theanyofoperator selects objects for which the specified field is an array that contain at least an element in the specified array.Criteriaanyof(java.util.Collection<?> c)Theanyofoperator selects objects for which the specified field is an array that contain at least an element in the specified array.booleanapply(Predicate.PredicateContext ctx)Criteriacontains(java.lang.Object o)Thecontainsoperator asserts that the provided object is contained in the result.static Criteriacreate(java.lang.String left, java.lang.String operator, java.lang.String right)Deprecated.Criteriaempty(boolean empty)ThenotEmptyoperator checks that an array or String is empty.Criteriaeq(java.lang.Object o)Creates a criterion using equalityCriteriaexists(boolean shouldExist)Check for existence (or lack thereof) of a field.Criteriagt(java.lang.Object o)Creates a criterion using the > operatorCriteriagte(java.lang.Object o)Creates a criterion using the >= operatorCriteriain(java.lang.Object... o)Theinoperator is analogous to the SQL IN modifier, allowing you to specify an array of possible matches.Criteriain(java.util.Collection<?> c)Theinoperator is analogous to the SQL IN modifier, allowing you to specify an array of possible matches.Criteriais(java.lang.Object o)Creates a criterion using equalityCriterialt(java.lang.Object o)Creates a criterion using the < operatorCriterialte(java.lang.Object o)Creates a criterion using the <= operatorCriteriamatches(Predicate p)Thematchesoperator checks that an object matches the given predicate.Criteriane(java.lang.Object o)Creates a criterion using the != operatorCriterianin(java.lang.Object... o)Theninoperator is similar to $in except that it selects objects for which the specified field does not have any value in the specified array.Criterianin(java.util.Collection<?> c)Theninoperator is similar to $in except that it selects objects for which the specified field does not have any value in the specified array.Criterianoneof(java.lang.Object... o)Thenoneofoperator selects objects for which the specified field is an array that does not contain any of the elements of the specified array.Criterianoneof(java.util.Collection<?> c)Thenoneofoperator selects objects for which the specified field is an array that does not contain any of the elements of the specified array.CriterianotEmpty()Deprecated.static Criteriaparse(java.lang.String criteria)Deprecated.Criteriaregex(java.util.regex.Pattern pattern)Creates a criterion using a RegexCriteriasize(int size)Thesizeoperator matches:Criteriasubsetof(java.lang.Object... o)Thesubsetofoperator selects objects for which the specified field is an array whose elements comprise a subset of the set comprised by the elements of the specified array.Criteriasubsetof(java.util.Collection<?> c)Thesubsetofoperator selects objects for which the specified field is an array whose elements comprise a subset of the set comprised by the elements of the specified array.java.lang.StringtoString()Criteriatype(java.lang.Class<?> clazz)The $type operator matches values based on their Java JSON type.static Criteriawhere(Path key)Deprecated.static Criteriawhere(java.lang.String key)Static factory method to create a Criteria using the provided key
-
-
-
Method Detail
-
apply
public boolean apply(Predicate.PredicateContext ctx)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
where
@Deprecated public static Criteria where(Path key)
Deprecated.Static factory method to create a Criteria using the provided key- Parameters:
key- filed name- Returns:
- the new criteria
-
where
public static Criteria where(java.lang.String key)
Static factory method to create a Criteria using the provided key- Parameters:
key- filed name- Returns:
- the new criteria
-
and
public Criteria and(java.lang.String key)
Static factory method to create a Criteria using the provided key- Parameters:
key- ads new filed to criteria- Returns:
- the criteria builder
-
is
public Criteria is(java.lang.Object o)
Creates a criterion using equality- Parameters:
o-- Returns:
- the criteria
-
eq
public Criteria eq(java.lang.Object o)
Creates a criterion using equality- Parameters:
o-- Returns:
- the criteria
-
ne
public Criteria ne(java.lang.Object o)
Creates a criterion using the != operator- Parameters:
o-- Returns:
- the criteria
-
lt
public Criteria lt(java.lang.Object o)
Creates a criterion using the < operator- Parameters:
o-- Returns:
- the criteria
-
lte
public Criteria lte(java.lang.Object o)
Creates a criterion using the <= operator- Parameters:
o-- Returns:
- the criteria
-
gt
public Criteria gt(java.lang.Object o)
Creates a criterion using the > operator- Parameters:
o-- Returns:
- the criteria
-
gte
public Criteria gte(java.lang.Object o)
Creates a criterion using the >= operator- Parameters:
o-- Returns:
- the criteria
-
regex
public Criteria regex(java.util.regex.Pattern pattern)
Creates a criterion using a Regex- Parameters:
pattern-- Returns:
- the criteria
-
in
public Criteria in(java.lang.Object... o)
Theinoperator is analogous to the SQL IN modifier, allowing you to specify an array of possible matches.- Parameters:
o- the values to match against- Returns:
- the criteria
-
in
public Criteria in(java.util.Collection<?> c)
Theinoperator is analogous to the SQL IN modifier, allowing you to specify an array of possible matches.- Parameters:
c- the collection containing the values to match against- Returns:
- the criteria
-
contains
public Criteria contains(java.lang.Object o)
Thecontainsoperator asserts that the provided object is contained in the result. The object that should contain the input can be either an object or a String.- Parameters:
o- that should exists in given collection or- Returns:
- the criteria
-
nin
public Criteria nin(java.lang.Object... o)
Theninoperator is similar to $in except that it selects objects for which the specified field does not have any value in the specified array.- Parameters:
o- the values to match against- Returns:
- the criteria
-
nin
public Criteria nin(java.util.Collection<?> c)
Theninoperator is similar to $in except that it selects objects for which the specified field does not have any value in the specified array.- Parameters:
c- the values to match against- Returns:
- the criteria
-
subsetof
public Criteria subsetof(java.lang.Object... o)
Thesubsetofoperator selects objects for which the specified field is an array whose elements comprise a subset of the set comprised by the elements of the specified array.- Parameters:
o- the values to match against- Returns:
- the criteria
-
subsetof
public Criteria subsetof(java.util.Collection<?> c)
Thesubsetofoperator selects objects for which the specified field is an array whose elements comprise a subset of the set comprised by the elements of the specified array.- Parameters:
c- the values to match against- Returns:
- the criteria
-
anyof
public Criteria anyof(java.lang.Object... o)
Theanyofoperator selects objects for which the specified field is an array that contain at least an element in the specified array.- Parameters:
o- the values to match against- Returns:
- the criteria
-
anyof
public Criteria anyof(java.util.Collection<?> c)
Theanyofoperator selects objects for which the specified field is an array that contain at least an element in the specified array.- Parameters:
c- the values to match against- Returns:
- the criteria
-
noneof
public Criteria noneof(java.lang.Object... o)
Thenoneofoperator selects objects for which the specified field is an array that does not contain any of the elements of the specified array.- Parameters:
o- the values to match against- Returns:
- the criteria
-
noneof
public Criteria noneof(java.util.Collection<?> c)
Thenoneofoperator selects objects for which the specified field is an array that does not contain any of the elements of the specified array.- Parameters:
c- the values to match against- Returns:
- the criteria
-
all
public Criteria all(java.lang.Object... o)
Thealloperator is similar to $in, but instead of matching any value in the specified array all values in the array must be matched.- Parameters:
o-- Returns:
- the criteria
-
all
public Criteria all(java.util.Collection<?> c)
Thealloperator is similar to $in, but instead of matching any value in the specified array all values in the array must be matched.- Parameters:
c-- Returns:
- the criteria
-
size
public Criteria size(int size)
Thesizeoperator matches:- array with the specified number of elements.
- string with given length.
- Parameters:
size-- Returns:
- the criteria
-
type
public Criteria type(java.lang.Class<?> clazz)
The $type operator matches values based on their Java JSON type. Supported types are: List.class Map.class String.class Number.class Boolean.class Other types evaluates to false- Parameters:
clazz-- Returns:
- the criteria
-
exists
public Criteria exists(boolean shouldExist)
Check for existence (or lack thereof) of a field.- Parameters:
shouldExist-- Returns:
- the criteria
-
notEmpty
@Deprecated public Criteria notEmpty()
Deprecated.ThenotEmptyoperator checks that an array or String is not empty.- Returns:
- the criteria
-
empty
public Criteria empty(boolean empty)
ThenotEmptyoperator checks that an array or String is empty.- Parameters:
empty- should be empty- Returns:
- the criteria
-
matches
public Criteria matches(Predicate p)
Thematchesoperator checks that an object matches the given predicate.- Parameters:
p-- Returns:
- the criteria
-
parse
@Deprecated public static Criteria parse(java.lang.String criteria)
Deprecated.Parse the provided criteria Deprecated useFilter.parse(String)- Parameters:
criteria-- Returns:
- a criteria
-
create
@Deprecated public static Criteria create(java.lang.String left, java.lang.String operator, java.lang.String right)
Deprecated.Creates a new criteria- Parameters:
left- path to evaluate in criteriaoperator- operatorright- expected value- Returns:
- a new Criteria
-
-