Class Criteria

java.lang.Object
com.jayway.jsonpath.Criteria
All Implemented Interfaces:
Predicate

public class Criteria extends Object implements Predicate
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.jayway.jsonpath.Predicate

    Predicate.PredicateContext
  • Method Summary

    Modifier and Type
    Method
    Description
    all(Object... o)
    The all operator is similar to $in, but instead of matching any value in the specified array all values in the array must be matched.
    The all operator is similar to $in, but instead of matching any value in the specified array all values in the array must be matched.
    and(String key)
    Static factory method to create a Criteria using the provided key
    anyof(Object... o)
    The anyof operator selects objects for which the specified field is an array that contain at least an element in the specified array.
    The anyof operator selects objects for which the specified field is an array that contain at least an element in the specified array.
    boolean
     
    The contains operator asserts that the provided object is contained in the result.
    static Criteria
    create(String left, String operator, String right)
    Deprecated.
    empty(boolean empty)
    The notEmpty operator checks that an array or String is empty.
    Creates a criterion using equality
    exists(boolean shouldExist)
    Check for existence (or lack thereof) of a field.
    Creates a criterion using the > operator
    Creates a criterion using the >= operator
    in(Object... o)
    The in operator is analogous to the SQL IN modifier, allowing you to specify an array of possible matches.
    in(Collection<?> c)
    The in operator is analogous to the SQL IN modifier, allowing you to specify an array of possible matches.
    Creates a criterion using equality
    Creates a criterion using the < operator
    Creates a criterion using the <= operator
    The matches operator checks that an object matches the given predicate.
    Creates a criterion using the != operator
    nin(Object... o)
    The nin operator is similar to $in except that it selects objects for which the specified field does not have any value in the specified array.
    The nin operator is similar to $in except that it selects objects for which the specified field does not have any value in the specified array.
    noneof(Object... o)
    The noneof operator selects objects for which the specified field is an array that does not contain any of the elements of the specified array.
    The noneof operator selects objects for which the specified field is an array that does not contain any of the elements of the specified array.
    Deprecated.
    static Criteria
    parse(String criteria)
    Deprecated.
    regex(Pattern pattern)
    Creates a criterion using a Regex
    size(int size)
    The size operator matches:
    The subsetof operator 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.
    The subsetof operator 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.
     
    type(Class<?> clazz)
    The $type operator matches values based on their Java JSON type.
    static Criteria
    where(Path key)
    Deprecated.
    static Criteria
    Static factory method to create a Criteria using the provided key

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • apply

      public boolean apply(Predicate.PredicateContext ctx)
      Specified by:
      apply in interface Predicate
    • toString

      public String toString()
      Overrides:
      toString in class 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(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(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(Object o)
      Creates a criterion using equality
      Parameters:
      o -
      Returns:
      the criteria
    • eq

      public Criteria eq(Object o)
      Creates a criterion using equality
      Parameters:
      o -
      Returns:
      the criteria
    • ne

      public Criteria ne(Object o)
      Creates a criterion using the != operator
      Parameters:
      o -
      Returns:
      the criteria
    • lt

      public Criteria lt(Object o)
      Creates a criterion using the < operator
      Parameters:
      o -
      Returns:
      the criteria
    • lte

      public Criteria lte(Object o)
      Creates a criterion using the <= operator
      Parameters:
      o -
      Returns:
      the criteria
    • gt

      public Criteria gt(Object o)
      Creates a criterion using the > operator
      Parameters:
      o -
      Returns:
      the criteria
    • gte

      public Criteria gte(Object o)
      Creates a criterion using the >= operator
      Parameters:
      o -
      Returns:
      the criteria
    • regex

      public Criteria regex(Pattern pattern)
      Creates a criterion using a Regex
      Parameters:
      pattern -
      Returns:
      the criteria
    • in

      public Criteria in(Object... o)
      The in 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(Collection<?> c)
      The in 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(Object o)
      The contains 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(Object... o)
      The nin 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(Collection<?> c)
      The nin 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
    • subsetof

      public Criteria subsetof(Object... o)
      The subsetof operator 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(Collection<?> c)
      The subsetof operator 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(Object... o)
      The anyof operator 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(Collection<?> c)
      The anyof operator 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(Object... o)
      The noneof operator 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(Collection<?> c)
      The noneof operator 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(Object... o)
      The all 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(Collection<?> c)
      The all 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)
      The size operator matches:

      1. array with the specified number of elements.
      2. string with given length.
      Parameters:
      size -
      Returns:
      the criteria
    • type

      public Criteria type(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.
      The notEmpty operator checks that an array or String is not empty.
      Returns:
      the criteria
    • empty

      public Criteria empty(boolean empty)
      The notEmpty operator checks that an array or String is empty.
      Parameters:
      empty - should be empty
      Returns:
      the criteria
    • matches

      public Criteria matches(Predicate p)
      The matches operator checks that an object matches the given predicate.
      Parameters:
      p -
      Returns:
      the criteria
    • parse

      @Deprecated public static Criteria parse(String criteria)
      Deprecated.
      Parse the provided criteria Deprecated use Filter.parse(String)
      Parameters:
      criteria -
      Returns:
      a criteria
    • create

      @Deprecated public static Criteria create(String left, String operator, String right)
      Deprecated.
      Creates a new criteria
      Parameters:
      left - path to evaluate in criteria
      operator - operator
      right - expected value
      Returns:
      a new Criteria