Interface Filter

All Known Implementing Classes:
ComparableFilter, FieldBasedFilter, IndexOnlyFilter, IndexScanFilter, LogicalFilter, NitriteFilter, SortingAwareFilter, StringFilter

public interface Filter
An interface to specify filtering criteria during find operation. When a filter is applied to a collection, based on the criteria it returns a set of matching records.

Each filtering criteria is based on a field of a document. If the field is indexed, the find operation takes the advantage of it and only scans the index map for that field. But if the field is not indexed, it scans the whole collection.

Since:
1.0
Author:
Anindya Chatterjee
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Filter
    A filter to select all elements.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Filter
    and(Filter... filters)
    Creates a filter that performs a logical AND operation on two or more filters.
    boolean
    Applies the filter to the given element.
    static Filter
    byId(NitriteId nitriteId)
    Returns a filter that matches documents with the specified NitriteId.
    default Filter
    not()
    Creates a not filter which performs a logical NOT operation on a filter and selects the documents that do not satisfy the criteria.
    static Filter
    or(Filter... filters)
    Creates a filter that performs a logical OR operation on two or more filters.
  • Field Details

    • ALL

      static final Filter ALL
      A filter to select all elements.
  • Method Details

    • byId

      static Filter byId(NitriteId nitriteId)
      Returns a filter that matches documents with the specified NitriteId.

      The returned filter matches documents where the value of the _id field is equal to the specified NitriteId's idValue.

      Parameters:
      nitriteId - the nitrite id
      Returns:
      the filter
    • and

      static Filter and(Filter... filters)
      Creates a filter that performs a logical AND operation on two or more filters. The returned filter accepts a document if all filters in the list accept the document.
      Parameters:
      filters - the filters to AND together
      Returns:
      the new filter
      Throws:
      FilterException - if less than two filters are specified
    • or

      static Filter or(Filter... filters)
      Creates a filter that performs a logical OR operation on two or more filters. The returned filter selects all documents that satisfy at least one of the filters in the list.
      Parameters:
      filters - the filters to be combined using the OR operation
      Returns:
      the filter that performs the OR operation on the specified filters
      Throws:
      FilterException - if less than two filters are specified
    • apply

      boolean apply(Pair<NitriteId,Document> element)
      Applies the filter to the given element.
      Parameters:
      element - the element to apply the filter to.
      Returns:
      true if the element matches the filter, false otherwise.
    • not

      default Filter not()
      Creates a not filter which performs a logical NOT operation on a filter and selects the documents that do not satisfy the criteria.

      NOTE: This also includes documents that do not contain the value.

      Returns:
      the not filter