Class AbstractConstraint

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int BOTH_FALSE
      Describes two constraints as being both false.
      static int BOTH_TRUE
      Describes two constraints as being both true.
      static int EQUAL
      Describes one constraint as being equal to another constraint.
      static int EXCLUDES
      Describes two constraints as being mutually exclusive.
      static int IMPLIED_BY
      Describes one constraint as being implied by another constraint.
      static int IMPLIES
      Describes one constraint as implying another constraint.
      static int INDEPENDENT
      Describes two constraints as being independent.
      static int LEFT_FALSE
      Describes two constraints, where the left is always false.
      static int LEFT_FALSE_RIGHT_TRUE
      Describes two constraints, where the left is always false, and the right is always true.
      static int LEFT_TRUE
      Describes two constraints, where the left is always true.
      static int LEFT_TRUE_RIGHT_FALSE
      Describes two constraints, where the left is always true, and the right is always false.
      static int OPPOSITE
      Describes two constraints as being opposite to each other.
      static int OR
      Describes two constraints as following "constraint 1 OR constraint 2 IS TRUE".
      static int RIGHT_FALSE
      Describes two constraints, where the right is always false.
      static int RIGHT_TRUE
      Describes two constraints, where the right is always true.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected static int alterComparisonAnd​(int compA, int compB)
      Take a couple of integers as if they are values returned by compare, and assume that they are two loose (and possibly different) descriptions of the relation between the same two AbstractConstraints, and return a value that is a more strict description.
      protected static int alterComparisonAORB​(int compA, int compB)
      Take a couple of integers as if they are values returned by compare, for this compared to A, and this compared to B, and return the value that compare should return for this compared to (A OR B).
      protected static int alterComparisonNotObj​(int comp)
      Take an integer as if it is a value returned by compare, and return the value that compare would have returned if second constraint (obj) had been NOTed.
      protected static int alterComparisonNotThis​(int comp)
      Take an integer as if it is a value returned by compare, and return the value that compare would have returned if first constraint (this) had been NOTed.
      protected static int alterComparisonSwitch​(int comp)
      Take an integer as if it is a value returned by compare, and return the value that compare would have returned if this and obj had been switched.
      static boolean checkComparisonEquals​(int comparison)
      Take an integer as if it was created by compare, and return true if this implies that the left constraint is EQUAL to the right constraint, in a loose sense.
      static boolean checkComparisonImplies​(int comparison)
      Take an integer as if it was created by compare, and return true if this implies that the left constraint IMPLIES the right constraint, in a loose sense.
      int compare​(AbstractConstraint obj)
      Compare this AbstractConstraint with another, ignoring aliases in member fields and tables.
      abstract int compare​(AbstractConstraint obj, java.util.Map<AbstractTable,​AbstractTable> tableMap, java.util.Map<AbstractTable,​AbstractTable> reverseTableMap)
      Compare this AbstractConstraint with another, ignoring aliases in member fields and tables.
      boolean equals​(java.lang.Object obj)
      Overrides Object.equals();
      abstract java.lang.String getSQLString()
      Returns a String representation of this AbstractConstraint object, suitable for forming part of an SQL query.
      abstract int hashCode()
      Overrides Object.hashcode();
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INDEPENDENT

        public static final int INDEPENDENT
        Describes two constraints as being independent. That is, knowing the result of one constraint tells one nothing about the result of another constraint.
        For example, "a > 5" and "b < 4".
        See Also:
        Constant Field Values
      • IMPLIED_BY

        public static final int IMPLIED_BY
        Describes one constraint as being implied by another constraint. That is, if the second constraint is true, then the first constraint must also be true. This can also be thought of as the first constraint being less restrictive than the second.
        For example, "a > 5" and "a = 8".
        See Also:
        Constant Field Values
      • IMPLIES

        public static final int IMPLIES
        Describes one constraint as implying another constraint. That is, if the first constraint is true, then the second constraint must also be true. This can also be thought of as the first constraint being more restrictive than the second.
        For example, "a > 5" and "a > 2".
        See Also:
        Constant Field Values
      • EQUAL

        public static final int EQUAL
        Describes one constraint as being equal to another constraint. That is, the result of the first constraint is always the same as the result of the second constraint.
        See Also:
        Constant Field Values
      • OPPOSITE

        public static final int OPPOSITE
        Describes two constraints as being opposite to each other. That is, the result of the first constraint is always the opposite of the result of the second constraint.
        For example, "a > 5" and "a ≤ 5".
        See Also:
        Constant Field Values
      • EXCLUDES

        public static final int EXCLUDES
        Describes two constraints as being mutually exclusive. That is, the results of both constraints cannot be true at the same time.
        For example, "a > 5" and "a < 5".
        See Also:
        Constant Field Values
      • OR

        public static final int OR
        Describes two constraints as following "constraint 1 OR constraint 2 IS TRUE". That is, at least one of the results of the two constraints must be true.
        For example, "a > 5" and "a < 8".
        See Also:
        Constant Field Values
      • BOTH_TRUE

        public static final int BOTH_TRUE
        Describes two constraints as being both true. This is a subset of EQUAL.
        See Also:
        Constant Field Values
      • BOTH_FALSE

        public static final int BOTH_FALSE
        Describes two constraints as being both false. This is a subset of EQUAL.
        See Also:
        Constant Field Values
      • LEFT_TRUE_RIGHT_FALSE

        public static final int LEFT_TRUE_RIGHT_FALSE
        Describes two constraints, where the left is always true, and the right is always false. This is the opposite of IMPLIES.
        See Also:
        Constant Field Values
      • LEFT_FALSE_RIGHT_TRUE

        public static final int LEFT_FALSE_RIGHT_TRUE
        Describes two constraints, where the left is always false, and the right is always true. This is the opposite of IMPLIED_BY.
        See Also:
        Constant Field Values
      • LEFT_TRUE

        public static final int LEFT_TRUE
        Describes two constraints, where the left is always true.
        See Also:
        Constant Field Values
      • LEFT_FALSE

        public static final int LEFT_FALSE
        Describes two constraints, where the left is always false.
        See Also:
        Constant Field Values
      • RIGHT_TRUE

        public static final int RIGHT_TRUE
        Describes two constraints, where the right is always true.
        See Also:
        Constant Field Values
      • RIGHT_FALSE

        public static final int RIGHT_FALSE
        Describes two constraints, where the right is always false.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractConstraint

        public AbstractConstraint()
    • Method Detail

      • getSQLString

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

        public int compare​(AbstractConstraint obj)
        Compare this AbstractConstraint with another, ignoring aliases in member fields and tables.
        Parameters:
        obj - an AbstractConstraint to compare to
        Returns:
        INDEPENDENT, IMPLIED_BY, IMPLIES, EQUAL, OPPOSITE, EXCLUDES, or OR, depending on the constraints.
      • compare

        public abstract int compare​(AbstractConstraint obj,
                                    java.util.Map<AbstractTable,​AbstractTable> tableMap,
                                    java.util.Map<AbstractTable,​AbstractTable> reverseTableMap)
        Compare this AbstractConstraint with another, ignoring aliases in member fields and tables.
        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.
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides Object.equals();
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the Object to compare to
        Returns:
        true if obj is the same
      • hashCode

        public abstract int hashCode()
        Overrides Object.hashcode();
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        an arbitrary integer based on the contents of the AbstractConstraint
      • alterComparisonNotThis

        protected static int alterComparisonNotThis​(int comp)
        Take an integer as if it is a value returned by compare, and return the value that compare would have returned if first constraint (this) had been NOTed. For example, if one passes in the value EQUAL, this method will return OPPOSITE.
        Parameters:
        comp - a previous comparison value returned by compare
        Returns:
        an alternative comparison value, for if this had been NOTed
      • alterComparisonNotObj

        protected static int alterComparisonNotObj​(int comp)
        Take an integer as if it is a value returned by compare, and return the value that compare would have returned if second constraint (obj) had been NOTed. For example, if one passes in the value IMPLIES, this method will return EXCLUSIVE (as it would now mean that the first implies not the second).
        Parameters:
        comp - a previous comparison value returned by compare
        Returns:
        an alternative comparison value, for if this had been NOTed
      • alterComparisonSwitch

        protected static int alterComparisonSwitch​(int comp)
        Take an integer as if it is a value returned by compare, and return the value that compare would have returned if this and obj had been switched. For example, IMPLIES gets translated to IMPLIED_BY.
        Parameters:
        comp - a previous comparison value returned by compare
        Returns:
        an alternative comparison value, for if this and obj had been switched
      • alterComparisonAORB

        protected static int alterComparisonAORB​(int compA,
                                                 int compB)
        Take a couple of integers as if they are values returned by compare, for this compared to A, and this compared to B, and return the value that compare should return for this compared to (A OR B).
        Parameters:
        compA - a previous comparison returned by compare for this.compare(A)
        compB - a previous comparison returned by compare for this.compare(B)
        Returns:
        an alternative comparison, for this.compare(A OR B)
      • alterComparisonAnd

        protected static int alterComparisonAnd​(int compA,
                                                int compB)
        Take a couple of integers as if they are values returned by compare, and assume that they are two loose (and possibly different) descriptions of the relation between the same two AbstractConstraints, and return a value that is a more strict description. For example, passing this method IMPLIES and IMPLIED_BY will return EQUAL.
        Parameters:
        compA - a previous comparison returned by compare.
        compB - another previous comparison returned by compare for the same set of AbstractConstraints.
        Returns:
        an alternative comparison which is the strictest comparison that can be infered from from the two input comparisons.
      • checkComparisonImplies

        public static boolean checkComparisonImplies​(int comparison)
        Take an integer as if it was created by compare, and return true if this implies that the left constraint IMPLIES the right constraint, in a loose sense. For example, a EQUALS b implies that a IMPLIES b.
        Parameters:
        comparison - the comparison to test
        Returns:
        true if this is a subset of IMPLIES
      • checkComparisonEquals

        public static boolean checkComparisonEquals​(int comparison)
        Take an integer as if it was created by compare, and return true if this implies that the left constraint is EQUAL to the right constraint, in a loose sense. For example the BOTH_TRUE comparison implies a EQUALS comparison.
        Parameters:
        comparison - the comparison to test
        Returns:
        true if this is a subset of EQUAL