Class FilterFactory

java.lang.Object
com.scaleout.client.caching.query.FilterFactory

public final class FilterFactory extends Object

This factory is used for constructing query expressions. Each of its methods return a filter (Filter) which can be in turn used to construct complex expressions. Methods of this class correspond to four types of operators, that may be used in query expressions:

  • equal, notEqual, greaterOrEqual, greaterThan, lessOrEqual, lessThan represent a comparison of a cached object property to a value. Property name is a name of an object's method annotated as an indexed attribute CacheObjectAttribute.
  • propertiesEqual, propertiesNotEqual, propertiesGreaterOrEqual, propertiesGreaterThan, propertiesLessOrEqual, propertiesLessThan represent a comparison of two properties of a cached object.
  • hasAllTags, hasAnyTags specify a conditions based on object tags. For a class to support tags, it must implement from Taggable.
  • and, or, not, expressionsEqual are combined operators which can be used to define a boolean logic combinations of all four types of operators.
For more compact code it is convenient to import all FilterFactory static methods:
     import static com.scaleout.client.filters.FilterFactory.*;
 
After doing this the expressions can be used as in following example:
     cache.queryKeys(not(and(equal("a", 0), equal("b", 1))), PlainClass.class);
 
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static Filter
    and(Filter firstFilter, Filter secondFilter)
    Creates a compound filter, matching objects must satisfy firstFilter AND secondFilter.
    static Filter
    contains(String propertyName, String str)
    The string property with the name propertyName must CONTAIN the string str.
    static Filter
    equal(String propertyName, Object value)
    The value of the property with the name propertyName must be EQUAL to value.
    static Filter
    expressionsEqual(Filter firstFilter, Filter secondFilter)
    To pass through this filter objects must satisfy both firstFilter and secondFilter or neither of them.
    static Filter
    greaterOrEqual(String propertyName, Object value)
    The value of the property with the name propertyName must be GREATER than OR EQUAL to value.
    static Filter
    greaterThan(String propertyName, Object value)
    The value of the property with the name propertyName must be GREATER than value.
    static Filter
    hasAllTags(String... tags)
    Matching objects must be tagged with ALL of the tags provided as parameters.
    static Filter
    hasAnyTags(String... tags)
    Matching objects must be tagged with ANY of the tags provided as parameters.
    static Filter
    isContained(String propertyName, String str)
    The string property with the name propertyName must be CONTAINED IN the string str.
    static Filter
    lessOrEqual(String propertyName, Object value)
    The value of the property with the name propertyName must be LESS than OR EQUAL to value.
    static Filter
    lessThan(String propertyName, Object value)
    The value of the property with the name propertyName must be LESS than value.
    static Filter
    not(Filter filter)
    Creates a compound filter, matching objects must NOT satisfy filter.
    static Filter
    notEqual(String propertyName, Object value)
    The value of the property with the name propertyName must NOT be EQUAL to value.
    static Filter
    or(Filter firstFilter, Filter secondFilter)
    Creates a compound filter, matching objects must satisfy firstFilter OR secondFilter.
    static Filter
    propertiesContains(String firstPropertyName, String secondPropertyName)
    The string property with the name propertyName must CONTAIN the string property with the name secondPropertyName.
    static Filter
    propertiesEqual(String firstPropertyName, String secondPropertyName)
    The two properties of matching objects must be EQUAL.
    static Filter
    propertiesGreaterOrEqual(String firstPropertyName, String secondPropertyName)
    The value of the property of the matching objects with the name firstPropertyName must be GREATER than OR EQUAL to that of the property with the name secondPropertyName.
    static Filter
    propertiesGreaterThan(String firstPropertyName, String secondPropertyName)
    The value of the property of the matching objects with the name firstPropertyName must be GREATER than that of the property with the name secondPropertyName.
    static Filter
    propertiesLessOrEqual(String firstPropertyName, String secondPropertyName)
    The value of the property of the matching objects with the name firstPropertyName must be LESS than OR EQUAL to that of the property with the name secondPropertyName.
    static Filter
    propertiesLessThan(String firstPropertyName, String secondPropertyName)
    The value of the property of the matching objects with the name firstPropertyName must be LESS than that of the property with the name secondPropertyName.
    static Filter
    propertiesNotEqual(String firstPropertyName, String secondPropertyName)
    The two properties of matching objects must NOT be EQUAL.

    Methods inherited from class java.lang.Object

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

    • and

      public static Filter and(Filter firstFilter, Filter secondFilter)
      Creates a compound filter, matching objects must satisfy firstFilter AND secondFilter.
      Parameters:
      firstFilter - first filter for the expression
      secondFilter - second filter for the expression
      Returns:
      resulting filter
    • or

      public static Filter or(Filter firstFilter, Filter secondFilter)
      Creates a compound filter, matching objects must satisfy firstFilter OR secondFilter.
      Parameters:
      firstFilter - first filter for the expression
      secondFilter - second filter for the expression
      Returns:
      resulting filter
    • not

      public static Filter not(Filter filter)
      Creates a compound filter, matching objects must NOT satisfy filter.
      Parameters:
      filter - filter for the expression
      Returns:
      resulting filter
    • equal

      public static Filter equal(String propertyName, Object value)
      The value of the property with the name propertyName must be EQUAL to value. The property should be annotated with CacheObjectAttribute.
      Parameters:
      propertyName - name of the property to match
      value - value to compare property with
      Returns:
      resulting filter
    • notEqual

      public static Filter notEqual(String propertyName, Object value)
      The value of the property with the name propertyName must NOT be EQUAL to value. The property should be annotated with CacheObjectAttribute.
      Parameters:
      propertyName - name of the property to match
      value - value to compare property with
      Returns:
      resulting filter
    • greaterOrEqual

      public static Filter greaterOrEqual(String propertyName, Object value)
      The value of the property with the name propertyName must be GREATER than OR EQUAL to value. The property should be annotated with CacheObjectAttribute.
      Parameters:
      propertyName - name of the property to match
      value - value to compare property with
      Returns:
      resulting filter
    • greaterThan

      public static Filter greaterThan(String propertyName, Object value)
      The value of the property with the name propertyName must be GREATER than value. The property should be annotated with CacheObjectAttribute.
      Parameters:
      propertyName - name of the property to match
      value - value to compare property with
      Returns:
      resulting filter
    • lessOrEqual

      public static Filter lessOrEqual(String propertyName, Object value)
      The value of the property with the name propertyName must be LESS than OR EQUAL to value. The property should be annotated with CacheObjectAttribute.
      Parameters:
      propertyName - name of the property to match
      value - value to compare property with
      Returns:
      resulting filter
    • lessThan

      public static Filter lessThan(String propertyName, Object value)
      The value of the property with the name propertyName must be LESS than value. The property should be annotated with CacheObjectAttribute.
      Parameters:
      propertyName - name of the property to match
      value - value to compare property with
      Returns:
      resulting filter
    • contains

      public static Filter contains(String propertyName, String str)
      The string property with the name propertyName must CONTAIN the string str. The property should be annotated with CacheObjectAttribute. This method is case sensitive.
      Parameters:
      propertyName - name of the property to match
      str - value to compare property with
      Returns:
      resulting filter
    • isContained

      public static Filter isContained(String propertyName, String str)
      The string property with the name propertyName must be CONTAINED IN the string str. The property should be annotated with CacheObjectAttribute. This method is case sensitive.
      Parameters:
      propertyName - name of the property to match
      str - value to compare property with
      Returns:
      resulting filter
    • propertiesEqual

      public static Filter propertiesEqual(String firstPropertyName, String secondPropertyName)
      The two properties of matching objects must be EQUAL. The properties should be annotated with CacheObjectAttribute.
      Parameters:
      firstPropertyName - name of the first property to match
      secondPropertyName - name of the second property to match
      Returns:
      resulting filter
    • propertiesNotEqual

      public static Filter propertiesNotEqual(String firstPropertyName, String secondPropertyName)
      The two properties of matching objects must NOT be EQUAL. The properties should be annotated with CacheObjectAttribute.
      Parameters:
      firstPropertyName - name of the first property to match
      secondPropertyName - name of the second property to match
      Returns:
      resulting filter
    • propertiesGreaterOrEqual

      public static Filter propertiesGreaterOrEqual(String firstPropertyName, String secondPropertyName)
      The value of the property of the matching objects with the name firstPropertyName must be GREATER than OR EQUAL to that of the property with the name secondPropertyName. The properties should be annotated with CacheObjectAttribute.
      Parameters:
      firstPropertyName - name of the first property to match
      secondPropertyName - name of the second property to match
      Returns:
      resulting filter
    • propertiesGreaterThan

      public static Filter propertiesGreaterThan(String firstPropertyName, String secondPropertyName)
      The value of the property of the matching objects with the name firstPropertyName must be GREATER than that of the property with the name secondPropertyName. The properties should be annotated with CacheObjectAttribute.
      Parameters:
      firstPropertyName - name of the first property to match
      secondPropertyName - name of the second property to match
      Returns:
      resulting filter
    • propertiesLessOrEqual

      public static Filter propertiesLessOrEqual(String firstPropertyName, String secondPropertyName)
      The value of the property of the matching objects with the name firstPropertyName must be LESS than OR EQUAL to that of the property with the name secondPropertyName. The properties should be annotated with CacheObjectAttribute.
      Parameters:
      firstPropertyName - name of the first property to match
      secondPropertyName - name of the second property to match
      Returns:
      resulting filter
    • propertiesLessThan

      public static Filter propertiesLessThan(String firstPropertyName, String secondPropertyName)
      The value of the property of the matching objects with the name firstPropertyName must be LESS than that of the property with the name secondPropertyName. The properties should be annotated with CacheObjectAttribute.
      Parameters:
      firstPropertyName - name of the first property to match
      secondPropertyName - name of the second property to match
      Returns:
      resulting filter
    • propertiesContains

      public static Filter propertiesContains(String firstPropertyName, String secondPropertyName)
      The string property with the name propertyName must CONTAIN the string property with the name secondPropertyName.
      Parameters:
      firstPropertyName - name of the first property to match
      secondPropertyName - name of the second property to match
      Returns:
      resulting filter
    • hasAllTags

      public static Filter hasAllTags(String... tags)
      Matching objects must be tagged with ALL of the tags provided as parameters. Objects should implement Taggable.
      Parameters:
      tags - tags to be present
      Returns:
      resulting filter
    • hasAnyTags

      public static Filter hasAnyTags(String... tags)
      Matching objects must be tagged with ANY of the tags provided as parameters. Objects should implement Taggable.
      Parameters:
      tags - tags to be present
      Returns:
      resulting filter
    • expressionsEqual

      public static Filter expressionsEqual(Filter firstFilter, Filter secondFilter)
      To pass through this filter objects must satisfy both firstFilter and secondFilter or neither of them.
      Parameters:
      firstFilter - first filter for the expression
      secondFilter - second filter for the expression
      Returns:
      resulting filter