Package org.intermine.sql.query
Class Constraint
- java.lang.Object
-
- org.intermine.sql.query.AbstractConstraint
-
- org.intermine.sql.query.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 Summary
Fields Modifier and Type Field Description static int
EQ
An operation for this constraint indicating that left is equal to right.static int
GORNULL
An operation for this constraint indicating that the left is greater than the right, or the left is null.protected AbstractValue
left
static int
LIKE
An operation for this constraint indicating that left should be pattern-matched against right.static int
LT
An operation for this constraint indicating that left is less than right.protected int
operation
protected AbstractValue
right
-
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 Constraint(AbstractValue left, int operation, AbstractValue right)
Constructor for a Constraint object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.AbstractValue
getLeft()
Returns the left argument of the constraint.int
getOperation()
Returns the operation of the constraint.AbstractValue
getRight()
Returns the right argument of the constraint.java.lang.String
getSQLString()
Returns a String representation of this Constraint object, suitable for forming part of an SQL query.int
hashCode()
Overrides Object.hashCode().java.lang.String
toString()
-
Methods inherited from class org.intermine.sql.query.AbstractConstraint
alterComparisonAnd, alterComparisonAORB, alterComparisonNotObj, alterComparisonNotThis, alterComparisonSwitch, checkComparisonEquals, checkComparisonImplies, compare, equals
-
-
-
-
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
-
left
protected AbstractValue left
-
right
protected AbstractValue right
-
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 constraintoperation
- 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 leftright
- 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 classjava.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 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 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 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.
-
hashCode
public int hashCode()
Overrides Object.hashCode().- Specified by:
hashCode
in classAbstractConstraint
- 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
-
-