Class Restriction


  • public class Restriction
    extends Object
    A simple bean which defines a restriction in a search, this is like saying: where userId = '123'; OR where userId like '%aaronz%';
    Example usage:
    Restriction rteq = new Restriction("title", curTitle); // restrict search to title equals value of curTitle
    Restriction rtne = new Restriction("title", curTitle, Restriction.NOT_EQUALS); // restrict search to title not equals value of curTitle
    Author:
    Aaron Zeckoski (azeckoski@gmail.com)
    • Constructor Detail

      • Restriction

        public Restriction​(String property,
                           Object value)
        Simple restriction where the property must equal the value
        Parameters:
        property - the name of the field (property) in the persisted object
        value - the value of the property (can be an array of items)
      • Restriction

        public Restriction​(String property,
                           Object value,
                           int comparison)
        Restriction which defines the type of comparison to make between a property and value
        Parameters:
        property - the name of the field (property) in the persisted object
        value - the value of the property (can be an array of items)
        comparison - the comparison to make between the property and the value, use the defined constants: e.g. EQUALS, LIKE, etc...
    • Method Detail

      • getProperty

        public String getProperty()
        the name of the field (property) in the search
      • setProperty

        public void setProperty​(String property)
      • getValue

        public Object getValue()
        the value of the property (can be an array of items)
      • setValue

        public void setValue​(Object value)
      • getStringValue

        public String getStringValue()
        Returns:
        the string value of the property, converts arrays to strings automatically, if null then return ''
      • getBooleanValue

        public boolean getBooleanValue()
        Returns:
        the value as a boolean, will return false if it is null or cannot be converted to a boolean
      • getSingleValue

        public Object getSingleValue()
        Returns:
        the value if it is not an array or collection, if it is then return the first object in the array or collection, otherwise return null (including when value is null)
      • getArrayValue

        public Object[] getArrayValue()
        Returns:
        the value as an array if it is an array or a collection, if it is a single value then return null (also when value is null)
      • getComparison

        public int getComparison()
        the comparison to make between the property and the value, use the defined constants: e.g. EQUALS, LIKE, etc...
      • setComparison

        public void setComparison​(int comparison)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object