Class Filters

java.lang.Object
com.datastax.astra.client.model.Filters

public class Filters extends Object
Helper to create Filter
  • Method Summary

    Modifier and Type
    Method
    Description
    static Filter
    all(String fieldName, Object... values)
    Build a filter with the `$all` operator.
    static Filter
    and(Filter... filters)
    Creates a filter that performs a logical AND of the provided list of filters.
    static Filter
    and(Iterable<Filter> filters)
    Creates a filter that performs a logical AND of the provided list of filters.
    static Filter
    eq(Object value)
    Creates a filter that matches all documents where the value of _id field equals the specified value.
    static Filter
    eq(String fieldName, Object value)
    Help Building the filters.
    static Filter
    exists(String fieldName)
    Build a filter with the `$exists` operator.
    static Filter
    gt(String fieldName, Number value)
    Creates a filter that matches all documents where the value of the given field is greater than the specified value.
    static Filter
    gt(String fieldName, Instant value)
    Creates a filter that matches all documents where the value of the given field is greater than the specified value.
    static Filter
    gt(String fieldName, Calendar value)
    Creates a filter that matches all documents where the value of the given field is greater than the specified value.
    static Filter
    gt(String fieldName, Date value)
    Creates a filter that matches all documents where the value of the given field is greater than the specified value.
    static Filter
    gte(String fieldName, Number value)
    Creates a filter that matches all documents where the value of the given field is greater than or equal to the specified value.
    static Filter
    gte(String fieldName, Instant value)
    Creates a filter that matches all documents where the value of the given field is greater than or equal to the specified value.
    static Filter
    gte(String fieldName, Calendar value)
    Creates a filter that matches all documents where the value of the given field is greater than or equal to the specified value.
    static Filter
    gte(String fieldName, Date value)
    Creates a filter that matches all documents where the value of the given field is greater than or equal to the specified value.
    static Filter
    hasSize(String fieldName, int size)
    Build a filter with the `$hasSize` operator.
    static <V> Filter
    in(String fieldName, V... values)
    Creates a filter that matches all documents where the value of a field equals any value in the list of specified values.
    static Filter
    lt(String fieldName, Number value)
    Creates a filter that matches all documents where the value of the given field is less than the specified value.
    static Filter
    lt(String fieldName, Instant value)
    Creates a filter that matches all documents where the value of the given field is less than the specified value.
    static Filter
    lt(String fieldName, Calendar value)
    Creates a filter that matches all documents where the value of the given field is less than the specified value.
    static Filter
    lt(String fieldName, Date value)
    Creates a filter that matches all documents where the value of the given field is less than the specified value.
    static Filter
    lte(String fieldName, Number value)
    Creates a filter that matches all documents where the value of the given field is less than or equal to the specified value.
    static Filter
    lte(String fieldName, Instant value)
    Creates a filter that matches all documents where the value of the given field is less than or equal to the specified value.
    static Filter
    lte(String fieldName, Calendar value)
    Creates a filter that matches all documents where the value of the given field is less than or equal to the specified value.
    static Filter
    lte(String fieldName, Date value)
    Creates a filter that matches all documents where the value of the given field is less than or equal to the specified value.
    static Filter
    ne(String fieldName, Object value)
    Creates a filter that matches all documents where the value of the field name does not equal the specified value.
    static <V> Filter
    nin(String fieldName, V... values)
    Creates a filter that matches all documents where the value of a field equals any value in the list of specified values.
    static Filter
    not(Filter filter)
    Creates a filter that performs a logical NOT of the provided filter
    static Filter
    or(Filter... filters)
    Creates a filter that performs a logical OR of the provided list of filters.
    static Filter
    or(Iterable<Filter> filters)
    Creates a filter that performs a logical OR of the provided list of filters.

    Methods inherited from class java.lang.Object

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

    • eq

      public static Filter eq(Object value)
      Creates a filter that matches all documents where the value of _id field equals the specified value. Note that this doesn't actually generate a $eq operator, as the query language doesn't require it.
      Parameters:
      value - the value, which may be null
      Returns:
      the filter
    • eq

      public static Filter eq(String fieldName, Object value)
      Help Building the filters.
      Parameters:
      fieldName - current fieldName
      value - current fieldValue
      Returns:
      filter
    • ne

      public static Filter ne(String fieldName, Object value)
      Creates a filter that matches all documents where the value of the field name does not equal the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • gt

      public static Filter gt(String fieldName, Number value)
      Creates a filter that matches all documents where the value of the given field is greater than the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • gt

      public static Filter gt(String fieldName, Instant value)
      Creates a filter that matches all documents where the value of the given field is greater than the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • gt

      public static Filter gt(String fieldName, Date value)
      Creates a filter that matches all documents where the value of the given field is greater than the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • gt

      public static Filter gt(String fieldName, Calendar value)
      Creates a filter that matches all documents where the value of the given field is greater than the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • gte

      public static Filter gte(String fieldName, Number value)
      Creates a filter that matches all documents where the value of the given field is greater than or equal to the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • gte

      public static Filter gte(String fieldName, Instant value)
      Creates a filter that matches all documents where the value of the given field is greater than or equal to the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • gte

      public static Filter gte(String fieldName, Calendar value)
      Creates a filter that matches all documents where the value of the given field is greater than or equal to the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • gte

      public static Filter gte(String fieldName, Date value)
      Creates a filter that matches all documents where the value of the given field is greater than or equal to the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • lt

      public static Filter lt(String fieldName, Number value)
      Creates a filter that matches all documents where the value of the given field is less than the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • lt

      public static Filter lt(String fieldName, Date value)
      Creates a filter that matches all documents where the value of the given field is less than the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • lt

      public static Filter lt(String fieldName, Instant value)
      Creates a filter that matches all documents where the value of the given field is less than the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • lt

      public static Filter lt(String fieldName, Calendar value)
      Creates a filter that matches all documents where the value of the given field is less than the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • lte

      public static Filter lte(String fieldName, Number value)
      Creates a filter that matches all documents where the value of the given field is less than or equal to the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • lte

      public static Filter lte(String fieldName, Instant value)
      Creates a filter that matches all documents where the value of the given field is less than or equal to the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • lte

      public static Filter lte(String fieldName, Date value)
      Creates a filter that matches all documents where the value of the given field is less than or equal to the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • lte

      public static Filter lte(String fieldName, Calendar value)
      Creates a filter that matches all documents where the value of the given field is less than or equal to the specified value.
      Parameters:
      fieldName - the field name
      value - the value, which may be null
      Returns:
      the filter
    • hasSize

      public static Filter hasSize(String fieldName, int size)
      Build a filter with the `$hasSize` operator.
      Parameters:
      fieldName - target field
      size - value for size (positive integer)
      Returns:
      filter built
    • exists

      public static Filter exists(String fieldName)
      Build a filter with the `$exists` operator.
      Parameters:
      fieldName - target field
      Returns:
      filter built
    • all

      public static Filter all(String fieldName, Object... values)
      Build a filter with the `$all` operator.
      Parameters:
      fieldName - target field
      values - list of values for the condition
      Returns:
      filter built
    • in

      @SafeVarargs public static <V> Filter in(String fieldName, V... values)
      Creates a filter that matches all documents where the value of a field equals any value in the list of specified values.
      Type Parameters:
      V - the type of the values
      Parameters:
      fieldName - the field name
      values - the list of values
      Returns:
      the filter
    • nin

      @SafeVarargs public static <V> Filter nin(String fieldName, V... values)
      Creates a filter that matches all documents where the value of a field equals any value in the list of specified values.
      Type Parameters:
      V - the type of the values
      Parameters:
      fieldName - the field name
      values - the list of values
      Returns:
      the filter
    • and

      public static Filter and(Filter... filters)
      Creates a filter that performs a logical AND of the provided list of filters.
          and(eq("x", 1), lt("y", 3))
       
      will generate a MongoDB query like:
          { $and: [{x : 1}, {y : {$lt : 3}}]}
       
      Parameters:
      filters - the list of filters to and together
      Returns:
      the filter
    • and

      public static Filter and(Iterable<Filter> filters)
      Creates a filter that performs a logical AND of the provided list of filters.
          and(eq("x", 1), lt("y", 3))
       
      will generate a MongoDB query like:
          { $and: [{x : 1}, {y : {$lt : 3}}]}
       
      Parameters:
      filters - the list of filters to and together
      Returns:
      the filter
    • or

      public static Filter or(Iterable<Filter> filters)
      Creates a filter that performs a logical OR of the provided list of filters.
          or(eq("x", 1), lt("y", 3))
       
      will generate a query like:
          { $or: [{x : 1}, {y : {$lt : 3}}]}
       
      Parameters:
      filters - the list of filters to and together
      Returns:
      the filter
    • or

      public static Filter or(Filter... filters)
      Creates a filter that performs a logical OR of the provided list of filters.
          or(eq("x", 1), lt("y", 3))
       
      will generate a query like:
          { $or: [{x : 1}, {y : {$lt : 3}}]}
       
      Parameters:
      filters - the list of filters to and together
      Returns:
      the filter
    • not

      public static Filter not(Filter filter)
      Creates a filter that performs a logical NOT of the provided filter
          not(eq("x", 1))
       
      will generate a query like:
          { $and: [{x : 1}, {y : {$lt : 3}}]}
       
      Parameters:
      filter - the list of filters to and together
      Returns:
      the filter