Package cruise.umple.compiler
Class ConstraintOperator
java.lang.Object
cruise.umple.compiler.ConstraintVariable
cruise.umple.compiler.ConstraintOperator
- All Implemented Interfaces:
java.lang.Iterable<ConstraintVariable>
public class ConstraintOperator extends ConstraintVariable
ConstraintOperators encapsulate the branching of the constraint tree, where the branches occur at the operators, for example
[a<3&&b!="loved"]
the basic structure will look like
ConstraintOperator(&&)
/ \
ConstraintOperator(<) ConstraintOperator(!=)
/ \ / \
ConstraintAttribute(a) ConstraintNumberLiteral(3) ConstraintAttribute(b) ConstraintLiteral("loved")
With the extra complication that ConstraintTrees parent everything that are not ConstraintLiterals
-
Constructor Summary
Constructors Constructor Description ConstraintOperator(java.lang.String aValue)
-
Method Summary
Modifier and Type Method Description void
addOperand(ConstraintVariable variable)
Carefully adds the operand on one side of the operator or the other, for example string literals are added in front, regardless of how they are arranged in the inputted constraint takes care of making sure cardinality calls the numberOf method, and if there is a number it puts it as the right operand(flipping ordinal operators)boolean
addOrMoveSubConstraintAt(ConstraintVariable aSubConstraint, int index)
boolean
addSubConstraint(ConstraintVariable aSubConstraint)
boolean
addSubConstraintAt(ConstraintVariable aSubConstraint, int index)
void
correctForCardinality(ConstraintVariable variable)
Tries to set associations so that they will use the numberOf method for the size.void
correctForPrimitive()
switches the .equals() style method for the primitive == or !=void
delete()
boolean
equals(java.lang.Object obj)
void
flip()
If the number is being put on the right, when it was originally on the left, the operator has to flip, '>' to '<' and '<' to '>'ConstraintVariable
getLeft()
ConstraintVariable
getRight()
ConstraintVariable
getSubConstraint(int index)
java.util.List<ConstraintVariable>
getSubConstraints()
java.lang.String
getType()
Returns which kind of operator this is based on the number of operands it has.java.lang.String
getValue()
int
hashCode()
boolean
hasSubConstraints()
int
indexOfSubConstraint(ConstraintVariable aSubConstraint)
boolean
isNegatable()
java.util.Iterator<ConstraintVariable>
iterator()
Iterators over the left, then this, then the right.static int
maximumNumberOfSubConstraints()
static int
minimumNumberOfSubConstraints()
boolean
negate()
If this method is reached by the negateVariable in ConstraintTree it means that the parent ConstraintTree doesn't have to display the negation, the operator will handle it instead.int
numberOfSubConstraints()
boolean
removeSubConstraint(ConstraintVariable aSubConstraint)
boolean
setSubConstraints(ConstraintVariable... newSubConstraints)
boolean
setValue(java.lang.String aValue)
java.lang.String
toString()
-
Constructor Details
-
ConstraintOperator
public ConstraintOperator(java.lang.String aValue)
-
-
Method Details
-
setValue
public boolean setValue(java.lang.String aValue) -
getValue
public java.lang.String getValue() -
getLeft
-
getRight
-
getSubConstraint
-
getSubConstraints
-
numberOfSubConstraints
public int numberOfSubConstraints() -
hasSubConstraints
public boolean hasSubConstraints() -
indexOfSubConstraint
-
minimumNumberOfSubConstraints
public static int minimumNumberOfSubConstraints() -
maximumNumberOfSubConstraints
public static int maximumNumberOfSubConstraints() -
addSubConstraint
-
removeSubConstraint
-
setSubConstraints
-
addSubConstraintAt
-
addOrMoveSubConstraintAt
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
delete
public void delete()- Overrides:
delete
in classConstraintVariable
-
getType
public java.lang.String getType()Returns which kind of operator this is based on the number of operands it has.- Specified by:
getType
in classConstraintVariable
-
addOperand
Carefully adds the operand on one side of the operator or the other, for example string literals are added in front, regardless of how they are arranged in the inputted constraint takes care of making sure cardinality calls the numberOf method, and if there is a number it puts it as the right operand(flipping ordinal operators) -
correctForCardinality
Tries to set associations so that they will use the numberOf method for the size.- Parameters:
variable
- to the corrected
-
correctForPrimitive
public void correctForPrimitive()switches the .equals() style method for the primitive == or != -
flip
public void flip()If the number is being put on the right, when it was originally on the left, the operator has to flip, '>' to '<' and '<' to '>' -
isNegatable
public boolean isNegatable() -
negate
public boolean negate()If this method is reached by the negateVariable in ConstraintTree it means that the parent ConstraintTree doesn't have to display the negation, the operator will handle it instead. -
iterator
Iterators over the left, then this, then the right.- Specified by:
iterator
in interfacejava.lang.Iterable<ConstraintVariable>
- Overrides:
iterator
in classConstraintVariable
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-