Class Constraint

  • All Implemented Interfaces:
    SQLStringable

    public class Constraint
    extends AbstractConstraint
    A representation of a normal constraint, comparing two AbstractValue objects.
    Author:
    Matthew Wakeling, Andrew Varley
    • Field Detail

      • EQ

        public static final int EQ
        An operation for this constraint indicating that left is equal to right.
        See Also:
        Constant Field Values
      • LT

        public static final int LT
        An operation for this constraint indicating that left is less than right.
        See Also:
        Constant Field Values
      • LIKE

        public static final int LIKE
        An operation for this constraint indicating that left should be pattern-matched against right.
        See Also:
        Constant Field Values
      • GORNULL

        public static final int GORNULL
        An operation for this constraint indicating that the left is greater than the right, or the left is null.
        See Also:
        Constant Field Values
      • operation

        protected int operation
    • Constructor Detail

      • Constraint

        public Constraint​(AbstractValue left,
                          int operation,
                          AbstractValue right)
        Constructor for a Constraint object.
        Parameters:
        left - the AbstractValue on the left of the constraint
        operation - EQ for an equivalence constraint, LT for a Less-Than constraint, LIKE for a String pattern match constraint - right must be the pattern to match against the value of left
        right - the AbstractValue on the right of the constraint
        Throws:
        java.lang.IllegalArgumentException - if operation is not EQ, LT, or LIKE
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getSQLString

        public java.lang.String getSQLString()
        Returns a String representation of this Constraint object, suitable for forming part of an SQL query.
        Specified by:
        getSQLString in interface SQLStringable
        Specified by:
        getSQLString in class AbstractConstraint
        Returns:
        the String representation
      • compare

        public int compare​(AbstractConstraint obj,
                           java.util.Map<AbstractTable,​AbstractTable> tableMap,
                           java.util.Map<AbstractTable,​AbstractTable> reverseTableMap)
        Compare this Constraint with another AbstractConstraint, ignoring aliases in member fields and tables. Compare this AbstractConstraint with another, ignoring aliases in member fields and tables.
        Specified by:
        compare in class AbstractConstraint
        Parameters:
        obj - an AbstractConstraint to compare to
        tableMap - a Map from tables in this constraint to tables in obj
        reverseTableMap - a reverse of tableMap
        Returns:
        INDEPENDENT, IMPLIED_BY, IMPLIES, EQUAL, OPPOSITE, EXCLUDES, or OR, depending on the constraints.
      • hashCode

        public int hashCode()
        Overrides Object.hashCode().
        Specified by:
        hashCode in class AbstractConstraint
        Returns:
        an arbitrary integer based on the contents of the Constraint
      • getLeft

        public AbstractValue getLeft()
        Returns the left argument of the constraint.
        Returns:
        left
      • getRight

        public AbstractValue getRight()
        Returns the right argument of the constraint.
        Returns:
        right
      • getOperation

        public int getOperation()
        Returns the operation of the constraint.
        Returns:
        operation