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
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<Criteria>
criteriaChain
private RelationalOperator
criteriaType
private ValueNode
left
private ValueNode
right
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Criteria
all(java.lang.Object... o)
Theall
operator is similar to $in, but instead of matching any value in the specified array all values in the array must be matched.Criteria
all(java.util.Collection<?> c)
Theall
operator is similar to $in, but instead of matching any value in the specified array all values in the array must be matched.Criteria
and(java.lang.String key)
Static factory method to create a Criteria using the provided keyboolean
apply(Predicate.PredicateContext ctx)
private void
checkComplete()
Criteria
contains(java.lang.Object o)
Thecontains
operator asserts that the provided object is contained in the result.static Criteria
create(java.lang.String left, java.lang.String operator, java.lang.String right)
Deprecated.Criteria
empty(boolean empty)
ThenotEmpty
operator checks that an array or String is empty.Criteria
eq(java.lang.Object o)
Creates a criterion using equalityCriteria
exists(boolean shouldExist)
Check for existence (or lack thereof) of a field.Criteria
gt(java.lang.Object o)
Creates a criterion using the > operatorCriteria
gte(java.lang.Object o)
Creates a criterion using the >= operatorCriteria
in(java.lang.Object... o)
Thein
operator is analogous to the SQL IN modifier, allowing you to specify an array of possible matches.Criteria
in(java.util.Collection<?> c)
Thein
operator is analogous to the SQL IN modifier, allowing you to specify an array of possible matches.Criteria
is(java.lang.Object o)
Creates a criterion using equalityCriteria
lt(java.lang.Object o)
Creates a criterion using the < operatorCriteria
lte(java.lang.Object o)
Creates a criterion using the <= operatorCriteria
matches(Predicate p)
Thematches
operator checks that an object matches the given predicate.Criteria
ne(java.lang.Object o)
Creates a criterion using the != operatorCriteria
nin(java.lang.Object... o)
Thenin
operator is similar to $in except that it selects objects for which the specified field does not have any value in the specified array.Criteria
nin(java.util.Collection<?> c)
Thenin
operator is similar to $in except that it selects objects for which the specified field does not have any value in the specified array.Criteria
notEmpty()
Deprecated.static Criteria
parse(java.lang.String criteria)
Deprecated.private static java.lang.String
prefixPath(java.lang.String key)
Criteria
regex(java.util.regex.Pattern pattern)
Creates a criterion using a RegexCriteria
size(int size)
Thesize
operator matches:private java.util.Collection<RelationalExpressionNode>
toRelationalExpressionNodes()
java.lang.String
toString()
Criteria
type(java.lang.Class<?> clazz)
The $type operator matches values based on their Java JSON type.static Criteria
where(Path key)
Deprecated.static Criteria
where(java.lang.String key)
Static factory method to create a Criteria using the provided key
-
-
-
Field Detail
-
criteriaChain
private final java.util.List<Criteria> criteriaChain
-
left
private ValueNode left
-
criteriaType
private RelationalOperator criteriaType
-
right
private ValueNode right
-
-
Method Detail
-
apply
public boolean apply(Predicate.PredicateContext ctx)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toRelationalExpressionNodes
private java.util.Collection<RelationalExpressionNode> toRelationalExpressionNodes()
-
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)
Thein
operator 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)
Thein
operator 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)
Thecontains
operator 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)
Thenin
operator 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)
Thenin
operator 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
-
all
public Criteria all(java.lang.Object... o)
Theall
operator 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)
Theall
operator 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)
Thesize
operator 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.ThenotEmpty
operator checks that an array or String is not empty.- Returns:
- the criteria
-
empty
public Criteria empty(boolean empty)
ThenotEmpty
operator checks that an array or String is empty.- Parameters:
empty
- should be empty- Returns:
- the criteria
-
matches
public Criteria matches(Predicate p)
Thematches
operator 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
-
prefixPath
private static java.lang.String prefixPath(java.lang.String key)
-
checkComplete
private void checkComplete()
-
-