Package org.intermine.sql.query
Class ConstraintSet
- java.lang.Object
-
- org.intermine.sql.query.AbstractConstraint
-
- org.intermine.sql.query.ConstraintSet
-
- All Implemented Interfaces:
SQLStringable
public class ConstraintSet extends AbstractConstraint
A representation of a set of constraints ORed together.- Author:
- Matthew Wakeling
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<AbstractConstraint>
cons
-
Fields inherited from class org.intermine.sql.query.AbstractConstraint
BOTH_FALSE, BOTH_TRUE, EQUAL, EXCLUDES, IMPLIED_BY, IMPLIES, INDEPENDENT, LEFT_FALSE, LEFT_FALSE_RIGHT_TRUE, LEFT_TRUE, LEFT_TRUE_RIGHT_FALSE, OPPOSITE, OR, RIGHT_FALSE, RIGHT_TRUE
-
-
Constructor Summary
Constructors Constructor Description ConstraintSet()
Constructor for a ConstraintSet object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(AbstractConstraint obj)
Add an AbstractConstraint to this ConstraintSet.int
compare(AbstractConstraint obj, java.util.Map<AbstractTable,AbstractTable> tableMap, java.util.Map<AbstractTable,AbstractTable> reverseTableMap)
Compare this ConstraintSet with another AbstractConstraint, ignoring aliases in member fields and tables.java.util.Set<AbstractConstraint>
getConstraints()
Returns the Set of constraints forming this object.java.lang.String
getSQLString()
Returns a String representation of this ConstraintSet object, suitable for forming part of an SQL query.int
hashCode()
Overrides Object.hashCode().protected int
internalCompare(AbstractConstraint obj, java.util.Map<AbstractTable,AbstractTable> tableMap, java.util.Map<AbstractTable,AbstractTable> reverseTableMap)
Compare this ConstraintSet with another AbstractConstraint, ignoring aliases in member fields and tables.-
Methods inherited from class org.intermine.sql.query.AbstractConstraint
alterComparisonAnd, alterComparisonAORB, alterComparisonNotObj, alterComparisonNotThis, alterComparisonSwitch, checkComparisonEquals, checkComparisonImplies, compare, equals
-
-
-
-
Field Detail
-
cons
protected java.util.Set<AbstractConstraint> cons
-
-
Method Detail
-
add
public void add(AbstractConstraint obj)
Add an AbstractConstraint to this ConstraintSet.- Parameters:
obj
- an AbstractConstraint to add to this ConstraintSet- Throws:
java.lang.IllegalArgumentException
- if obj contains in any way a ConstraintSet. (This is to protect us from having anything but a simple Conjunctive Normal Form expression.)
-
getSQLString
public java.lang.String getSQLString()
Returns a String representation of this ConstraintSet object, suitable for forming part of an SQL query.- Specified by:
getSQLString
in interfaceSQLStringable
- Specified by:
getSQLString
in classAbstractConstraint
- Returns:
- the String representation
-
compare
public int compare(AbstractConstraint obj, java.util.Map<AbstractTable,AbstractTable> tableMap, java.util.Map<AbstractTable,AbstractTable> reverseTableMap)
Compare this ConstraintSet 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 classAbstractConstraint
- Parameters:
obj
- an AbstractConstraint to compare totableMap
- a Map from tables in this constraint to tables in objreverseTableMap
- a reverse of tableMap- Returns:
- INDEPENDENT, IMPLIED_BY, IMPLIES, EQUAL, OPPOSITE, EXCLUDES, or OR, depending on the constraints.
-
internalCompare
protected int internalCompare(AbstractConstraint obj, java.util.Map<AbstractTable,AbstractTable> tableMap, java.util.Map<AbstractTable,AbstractTable> reverseTableMap)
Compare this ConstraintSet with another AbstractConstraint, ignoring aliases in member fields and tables. If obj is a ConstraintSet, then the comparison returned is loose - that is, it accepts the possibility of an occurance that cannot actually happen. This is a safe operation, but to get a correct result, one should combine A.internalCompare(B) with B.internalCompare(A), using the AbstractConstraint.alterComparisonAnd method. Even then, we have not written a proof that this method returns a completely strict comparison.
Also, note that it is possible that this method will return values other than the seven recognised comparisons, if a ConstraintSet contains constraints that EXCLUDE each other or compare to each other with the OR comparison. This is alright - the value that the method has returned is merely more strict than the seven "useful" values are, and reflects the fact that one of the ConstraintSets is always true or false. We don't think we will be constructing any such ConstraintSets, so it ought to be alright.- Parameters:
obj
- an AbstractConstraint to compare totableMap
- a Map from tables in this constraint to tables in objreverseTableMap
- 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 classAbstractConstraint
- Returns:
- an arbitrary integer based on the contents of the Constraint
-
getConstraints
public java.util.Set<AbstractConstraint> getConstraints()
Returns the Set of constraints forming this object.- Returns:
- the Set of Constraints
-
-