Class ConstraintTree

java.lang.Object
cruise.umple.compiler.ConstraintVariable
cruise.umple.compiler.ConstraintTree
All Implemented Interfaces:
java.lang.Iterable<ConstraintVariable>
Direct Known Subclasses:
BasicConstraint, Guard, Postcondition, Precondition, TraceConstraint

public class ConstraintTree
extends ConstraintVariable
ConstraintTrees are a redundant class that are necessary because of lone constraints, i.e. [true] has to be handled, and does not contain an operator If lone constraints didn't exist then the ConstraintTree class could be condensed into ConstraintOperator. One nice religation of responsibilities is that ConstraintTrees take care of the ! and () symbols, leaving the ConstraintOperator class to be more pure NEW CLASS****************************************
  • Constructor Summary

    Constructors 
    Constructor Description
    ConstraintTree()  
  • Method Summary

    Modifier and Type Method Description
    ConstraintVariable addElement​(ConstraintVariable aElement)
    Adds a node to the tree, the three modes are - if nothing exists in the tree: set the element as the root - if the element is an operator: add the root if it is not null as an operand to the operator, and set the operator to the root - if there exists an operator: add the element as an operand to the operator.
    void addElementAll​(ConstraintVariable cv)
    Used by trees to add all the elements of another tree to this tree
    ConstraintTree clone​(ConstraintTree tree)
    Copies non-constraint data such as whether the tree should display the ! symbol and whether it should display ( ) around the treee
    ConstraintTree createNew()
    Creates a new instance of this class, it is used in clone and addElement in order to copy a tree so that there is a deep copy instead of a shallow one This method needs to be overrided for sub classes of ConstaintTree to function properly.
    void delete()  
    boolean equals​(java.lang.Object obj)  
    boolean getDisplayBrackets()  
    boolean getDisplayNegation()  
    java.lang.String getNamedNames()
    Whenever ConstraintTrees or named Constriants are added to the constraint tree, a record of that name is added to a set of names This method pretty prints that set of names.
    java.util.TreeSet<java.lang.String> getNames()  
    int getNumberOfElements()  
    ConstraintOperator getRequestor()  
    ConstraintVariable getRoot()  
    boolean getShouldDisplayBrackets()  
    java.lang.String getType()
    Mandatory type method for the SuperGenerator to distiguish easily between different ConstraintVariable types.
    int hashCode()  
    boolean isEqualTo​(ConstraintTree inConstraintTree)
    ---------------------------------------------------------------------------- ---------------------------------Start-------------------------------------- ----------------------------------------------------------------------------
    boolean isNegatable()
    The public counterpart to the isNegateVariabe method, it checks negativability of this ConstraintTree's root, starting off the recursive decent into the negation of the tree
    java.util.Iterator<ConstraintVariable> iterator()
    Iterator method, override the method from the Iterable interface that all ConstraintVariables inherit from Iterates over all of the root's elements, then returns itself
    boolean negate()
    The public counterpart to the negateVariabe method, it negates this ConstraintTree's root, starting off the recursive decent into the negation of the tree
    boolean setDisplayNegation​(boolean aDisplayNegation)  
    boolean setNames​(java.util.TreeSet<java.lang.String> aNames)  
    boolean setNumberOfElements​(int aNumberOfElements)  
    boolean setRequestor​(ConstraintOperator aRequestor)  
    boolean setRoot​(ConstraintVariable aRoot)  
    boolean setShouldDisplayBrackets​(boolean aShouldDisplayBrackets)  
    java.lang.String toString()  

    Methods inherited from class cruise.umple.compiler.ConstraintVariable

    getValue, retrieveClassifier

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

  • Method Details

    • setRoot

      public boolean setRoot​(ConstraintVariable aRoot)
    • setRequestor

      public boolean setRequestor​(ConstraintOperator aRequestor)
    • setNames

      public boolean setNames​(java.util.TreeSet<java.lang.String> aNames)
    • setShouldDisplayBrackets

      public boolean setShouldDisplayBrackets​(boolean aShouldDisplayBrackets)
    • setDisplayNegation

      public boolean setDisplayNegation​(boolean aDisplayNegation)
    • setNumberOfElements

      public boolean setNumberOfElements​(int aNumberOfElements)
    • getRoot

      public ConstraintVariable getRoot()
    • getRequestor

      public ConstraintOperator getRequestor()
    • getNames

      public java.util.TreeSet<java.lang.String> getNames()
    • getShouldDisplayBrackets

      public boolean getShouldDisplayBrackets()
    • getDisplayNegation

      public boolean getDisplayNegation()
    • getDisplayBrackets

      public boolean getDisplayBrackets()
    • getNumberOfElements

      public int getNumberOfElements()
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • delete

      public void delete()
      Overrides:
      delete in class ConstraintVariable
    • addElementAll

      public void addElementAll​(ConstraintVariable cv)
      Used by trees to add all the elements of another tree to this tree
      Parameters:
      cv - the constraint variable node to add to this tree(if it is a ConstraintTree it will add all of it's sub elements via the addElement method)
    • negate

      public boolean negate()
      The public counterpart to the negateVariabe method, it negates this ConstraintTree's root, starting off the recursive decent into the negation of the tree
    • isNegatable

      public boolean isNegatable()
      The public counterpart to the isNegateVariabe method, it checks negativability of this ConstraintTree's root, starting off the recursive decent into the negation of the tree
    • clone

      public ConstraintTree clone​(ConstraintTree tree)
      Copies non-constraint data such as whether the tree should display the ! symbol and whether it should display ( ) around the treee
    • createNew

      public ConstraintTree createNew()
      Creates a new instance of this class, it is used in clone and addElement in order to copy a tree so that there is a deep copy instead of a shallow one This method needs to be overrided for sub classes of ConstaintTree to function properly.
    • addElement

      public ConstraintVariable addElement​(ConstraintVariable aElement)
      Adds a node to the tree, the three modes are - if nothing exists in the tree: set the element as the root - if the element is an operator: add the root if it is not null as an operand to the operator, and set the operator to the root - if there exists an operator: add the element as an operand to the operator.
      Parameters:
      element - to be added to the tree
    • getNamedNames

      public java.lang.String getNamedNames()
      Whenever ConstraintTrees or named Constriants are added to the constraint tree, a record of that name is added to a set of names This method pretty prints that set of names.
    • iterator

      public java.util.Iterator<ConstraintVariable> iterator()
      Iterator method, override the method from the Iterable interface that all ConstraintVariables inherit from Iterates over all of the root's elements, then returns itself
      Specified by:
      iterator in interface java.lang.Iterable<ConstraintVariable>
      Overrides:
      iterator in class ConstraintVariable
    • getType

      public java.lang.String getType()
      Mandatory type method for the SuperGenerator to distiguish easily between different ConstraintVariable types.
      Specified by:
      getType in class ConstraintVariable
    • isEqualTo

      public boolean isEqualTo​(ConstraintTree inConstraintTree)
      ---------------------------------------------------------------------------- ---------------------------------Start-------------------------------------- ----------------------------------------------------------------------------
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object