Package org.intermine.objectstore.query
Class SimpleConstraint
- java.lang.Object
-
- org.intermine.objectstore.query.Constraint
-
- org.intermine.objectstore.query.SimpleConstraint
-
public class SimpleConstraint extends Constraint
Represents a constraint between two QueryEvaluable types. These are query elements that can be resolved to a value - fields, expressions, aggregate functions and constants. Constraint ops can be standard numeric comparison, IS_NULL, and also MATCHES for simple string pattern matching.- Author:
- Richard Smith, Mark Woodbridge, Matthew Wakeling
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.List<ConstraintOp>
ALL_OPS
protected static java.util.List<ConstraintOp>
BOOLEAN_OPS
protected static java.util.List<ConstraintOp>
DATE_OPS
protected static java.util.List<ConstraintOp>
NUMBER_OPS
protected QueryEvaluable
qe1
protected QueryEvaluable
qe2
protected static java.util.List<ConstraintOp>
STRING_OPS
-
Fields inherited from class org.intermine.objectstore.query.Constraint
op
-
-
Constructor Summary
Constructors Constructor Description SimpleConstraint(QueryEvaluable qe1, ConstraintOp op)
Construct a Constraint.SimpleConstraint(QueryEvaluable qe1, ConstraintOp op, QueryEvaluable qe2)
Construct a Constraint.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
comparable(java.lang.Class<?> arg1, java.lang.Class<?> arg2)
Check whether the two arguments are of comparable types i.e.boolean
equals(java.lang.Object obj)
Test whether two SimpleConstraints are equal, overrides Object.equals()static java.util.List<ConstraintOp>
fixedEnumOps(java.lang.Class<?> arg)
For an argument type which an enumerated value set, return the list of operators for which it makes sense only to provide the enumerated values and not allow the user to enter an arbitrary string.QueryEvaluable
getArg1()
Returns the left argument of the constraint.QueryEvaluable
getArg2()
Returns the right argument of the constraint.int
hashCode()
Get the hashCode for this object overrides Object.hashCode()java.lang.String
toString()
static boolean
validComparison(java.lang.Class<?> arg1, ConstraintOp op, java.lang.Class<?> arg2)
Check whether a comparison is valid i.e.static java.util.List<ConstraintOp>
validOps(java.lang.Class<?> arg)
Return the list of valid (binary) operator codes given arguments of a specified type-
Methods inherited from class org.intermine.objectstore.query.Constraint
getOp, negate
-
-
-
-
Field Detail
-
qe1
protected QueryEvaluable qe1
-
qe2
protected QueryEvaluable qe2
-
NUMBER_OPS
protected static final java.util.List<ConstraintOp> NUMBER_OPS
-
DATE_OPS
protected static final java.util.List<ConstraintOp> DATE_OPS
-
STRING_OPS
protected static final java.util.List<ConstraintOp> STRING_OPS
-
BOOLEAN_OPS
protected static final java.util.List<ConstraintOp> BOOLEAN_OPS
-
ALL_OPS
protected static final java.util.List<ConstraintOp> ALL_OPS
-
-
Constructor Detail
-
SimpleConstraint
public SimpleConstraint(QueryEvaluable qe1, ConstraintOp op, QueryEvaluable qe2)
Construct a Constraint. Check that java types of QueryEvaluables are compatible with the constraint type selected.- Parameters:
qe1
- first QueryEvaluable for comparisonop
- define comparison opqe2
- second QueryEvaluable for comparison- Throws:
java.lang.IllegalArgumentException
- if type does not correspond to a defined operation
-
SimpleConstraint
public SimpleConstraint(QueryEvaluable qe1, ConstraintOp op)
Construct a Constraint. Check that correct constraint op is selected for single QueryEvaluable constructor- Parameters:
qe1
- first QueryEvaluable for comparisonop
- define op of comparison- Throws:
java.lang.IllegalArgumentException
- if op does not correspond to a defined operation
-
-
Method Detail
-
getArg1
public QueryEvaluable getArg1()
Returns the left argument of the constraint.- Returns:
- the left-hand argument
-
getArg2
public QueryEvaluable getArg2()
Returns the right argument of the constraint.- Returns:
- the right-hand argument
-
equals
public boolean equals(java.lang.Object obj)
Test whether two SimpleConstraints are equal, overrides Object.equals()- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the object to compare with- Returns:
- true if objects are equal
-
hashCode
public int hashCode()
Get the hashCode for this object overrides Object.hashCode()- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hashCode
-
validComparison
public static boolean validComparison(java.lang.Class<?> arg1, ConstraintOp op, java.lang.Class<?> arg2)
Check whether a comparison is valid i.e. the arguments are comparable types and the the operator is permitted for those types- Parameters:
arg1
- the first argumentop
- how to compare the argumentsarg2
- the second argument- Returns:
- whether the comparison is valid
-
comparable
public static boolean comparable(java.lang.Class<?> arg1, java.lang.Class<?> arg2)
Check whether the two arguments are of comparable types i.e. they are of similiar type and we know how to handle that type- Parameters:
arg1
- the first argumentarg2
- the second argument- Returns:
- whether the types are comparable
-
validOps
public static java.util.List<ConstraintOp> validOps(java.lang.Class<?> arg)
Return the list of valid (binary) operator codes given arguments of a specified type- Parameters:
arg
- the argument type- Returns:
- an array of character codes
-
fixedEnumOps
public static java.util.List<ConstraintOp> fixedEnumOps(java.lang.Class<?> arg)
For an argument type which an enumerated value set, return the list of operators for which it makes sense only to provide the enumerated values and not allow the user to enter an arbitrary string.- Parameters:
arg
- the argument type- Returns:
- constraint operators that will only accept an enumerated value
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-