Class CompoundCriteria

  • All Implemented Interfaces:
    Cloneable, LanguageObject, Expression

    public class CompoundCriteria
    extends LogicalCriteria
    This class represents a compound criteria for logical expressions. A logical expression involves one or more criteria and a logical operator. The valid operators are "AND" and "OR".
    • Field Detail

      • OR

        public static final int OR
        Constant indicating the logical "or" of two or more criteria.
        See Also:
        Constant Field Values
      • AND

        public static final int AND
        Constant indicating the logical "and" of two or more criteria.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CompoundCriteria

        public CompoundCriteria()
        Constructs a default instance of this class.
      • CompoundCriteria

        public CompoundCriteria​(List<? extends Criteria> criteria)
        Constructs an instance of this class given the criteria. Subclasses are responsible for defining how the criteria are inter-related in a logical expression.
        Parameters:
        criteria - List of Criteria being added
      • CompoundCriteria

        public CompoundCriteria​(int operator,
                                Criteria left,
                                Criteria right)
        Constructs an instance of this class given a binary logical expression. The logical expression is constructed in terms of a left criteria clause, an operator (either OR or AND), and a right criteria clause.
        Parameters:
        left - The criteria left of the operator
        right - The criteria right of the operator
        operator - The logical operator
        See Also:
        set(int,Criteria,Criteria)
      • CompoundCriteria

        public CompoundCriteria​(int operator,
                                List criteria)
        Constructs an instance of this class given a general logical expression. The logical expression is constructed in terms of an operator (either OR or AND), and a set of criteria clauses.
        Parameters:
        operator - The logical operator
        criteria - The list of Criteria
    • Method Detail

      • getOperator

        public int getOperator()
        Returns the operator used in the logical expression. The returned value can be compared to constants defined in this class.
        Returns:
        The operator
      • setOperator

        public void setOperator​(int operator)
        Sets the operator used in the logical expression.
        Parameters:
        operator - The operator
        Throws:
        IllegalArgumentException - If operator is invalid
      • getCriteria

        public List<Criteria> getCriteria()
        Returns the list of criteria.
        Returns:
        List of Criteria
      • setCriteria

        public void setCriteria​(List<Criteria> criteria)
        Sets the criteria.
        Parameters:
        criteria - The list of Criteria
      • getCriteriaCount

        public int getCriteriaCount()
        Returns the number of criteria in this clause.
        Returns:
        Criteria
      • getCriteria

        public Criteria getCriteria​(int index)
        Returns the criteria at the specified index.
        Returns:
        Criteria
        Throws:
        IllegalArgumentException - if no criteria have been specified
      • addCriteria

        public void addCriteria​(Criteria criteria)
        Add another criteria to the clause.
        Parameters:
        criteria - The criteria
      • reset

        protected void reset()
        Reset criteria so there are no more. After this call, getCriteriaCount will return 0.
      • set

        public void set​(int operator,
                        Criteria left,
                        Criteria right)
        Sets a "standard" operand-operator-operand criteria.
        Parameters:
        operator - The logical operator
        left - The first criteria
        right - The second criteria
        See Also:
        set(int,List)
      • set

        public void set​(int operator,
                        Criteria criteria)
        Sets a "standard" unary criteria.
        Parameters:
        operator - The unary logical operator
        criteria - The criteria
        See Also:
        set(int,List)
      • set

        public void set​(int operator,
                        List criteria)
        Sets the operator and an arbitrary set of criteria.
        Parameters:
        operator - The logical operator
        criteria - The set of criteria
        See Also:
        set(int,Criteria,Criteria)
      • acceptVisitor

        public void acceptVisitor​(LanguageVisitor visitor)
        Description copied from interface: LanguageObject
        Method for accepting a visitor. It is the responsibility of the language object to call back on the visitor.
        Parameters:
        visitor - Visitor being used
      • hashCode

        public int hashCode()
        Get hash code. WARNING: The hash code is based on data in the criteria. If data values are changed, the hash code will change - don't hash this object and change values.
        Overrides:
        hashCode in class Object
      • equals

        public boolean equals​(Object obj)
        Override equals() method.
        Overrides:
        equals in class Object
      • clone

        public Object clone()
        Deep clone. It returns a new LogicalCriteria with a new list of clones of the criteria objects.
        Specified by:
        clone in interface LanguageObject
        Specified by:
        clone in class Criteria
        Returns:
        Deep clone of this criteria