Class AssignmentDetector

  • All Implemented Interfaces:
    net.ssehub.easy.varModel.cst.IConstraintTreeVisitor

    public class AssignmentDetector
    extends java.lang.Object
    implements net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
    Implements a visitor which searches for assignments. Instances of this class may be reused by calling clear() after use.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean isAssignment  
      private int level  
      static int LEVEL_UNLIMITED
      The level specification to be used if traversal shall not be limited.
      private int maxLevel  
      static int NO_DEEP_TRAVERSAL
      The level specification to be used if no deep traversal shall happen (just the top level).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clears this visitor for reuse.
      private boolean continueTraversal()
      Returns whether the traversal of the given constraint shall be continued in case of nested trees.
      boolean isAssignment()
      Returns whether the expression is an assignment at maximum at the given level.
      void setMaxLevel​(int level)
      Defines the maximum search level.
      void visitAnnotationVariable​(net.ssehub.easy.varModel.cst.AttributeVariable variable)  
      void visitBlockExpression​(net.ssehub.easy.varModel.cst.BlockExpression block)  
      void visitComment​(net.ssehub.easy.varModel.cst.Comment comment)  
      void visitCompoundAccess​(net.ssehub.easy.varModel.cst.CompoundAccess access)  
      void visitCompoundInitializer​(net.ssehub.easy.varModel.cst.CompoundInitializer initializer)  
      void visitConstantValue​(net.ssehub.easy.varModel.cst.ConstantValue value)  
      void visitContainerInitializer​(net.ssehub.easy.varModel.cst.ContainerInitializer initializer)  
      void visitContainerOperationCall​(net.ssehub.easy.varModel.cst.ContainerOperationCall call)  
      void visitDeferInitExpression​(net.ssehub.easy.varModel.cst.DeferInitExpression expression)  
      void visitIfThen​(net.ssehub.easy.varModel.cst.IfThen ifThen)  
      void visitLet​(net.ssehub.easy.varModel.cst.Let let)  
      void visitMultiAndExpression​(net.ssehub.easy.varModel.cst.MultiAndExpression expression)  
      void visitOclFeatureCall​(net.ssehub.easy.varModel.cst.OCLFeatureCall call)  
      void visitParenthesis​(net.ssehub.easy.varModel.cst.Parenthesis parenthesis)  
      void visitSelf​(net.ssehub.easy.varModel.cst.Self self)  
      void visitUnresolvedExpression​(net.ssehub.easy.varModel.cst.UnresolvedExpression expression)  
      void visitVariable​(net.ssehub.easy.varModel.cst.Variable variable)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LEVEL_UNLIMITED

        public static final int LEVEL_UNLIMITED
        The level specification to be used if traversal shall not be limited.
        See Also:
        Constant Field Values
      • NO_DEEP_TRAVERSAL

        public static final int NO_DEEP_TRAVERSAL
        The level specification to be used if no deep traversal shall happen (just the top level).
        See Also:
        Constant Field Values
      • isAssignment

        private boolean isAssignment
      • maxLevel

        private int maxLevel
      • level

        private int level
    • Constructor Detail

      • AssignmentDetector

        public AssignmentDetector()
    • Method Detail

      • setMaxLevel

        public void setMaxLevel​(int level)
        Defines the maximum search level.
        Parameters:
        level - the maximum search level, may be LEVEL_UNLIMITED in order to avoid any level limitation or NO_DEEP_TRAVERSAL in order to avoid
      • isAssignment

        public boolean isAssignment()
        Returns whether the expression is an assignment at maximum at the given level.
        Returns:
        true if it is an assignment, false else
      • clear

        public void clear()
        Clears this visitor for reuse.
      • visitConstantValue

        public void visitConstantValue​(net.ssehub.easy.varModel.cst.ConstantValue value)
        Specified by:
        visitConstantValue in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • visitVariable

        public void visitVariable​(net.ssehub.easy.varModel.cst.Variable variable)
        Specified by:
        visitVariable in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • visitAnnotationVariable

        public void visitAnnotationVariable​(net.ssehub.easy.varModel.cst.AttributeVariable variable)
        Specified by:
        visitAnnotationVariable in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • continueTraversal

        private boolean continueTraversal()
        Returns whether the traversal of the given constraint shall be continued in case of nested trees. Continuation is not needed if already an assignment has been found or the maximum level is exceeded.
        Returns:
        true if the traversal shall be continued, false else
      • visitParenthesis

        public void visitParenthesis​(net.ssehub.easy.varModel.cst.Parenthesis parenthesis)
        Specified by:
        visitParenthesis in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • visitComment

        public void visitComment​(net.ssehub.easy.varModel.cst.Comment comment)
        Specified by:
        visitComment in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • visitOclFeatureCall

        public void visitOclFeatureCall​(net.ssehub.easy.varModel.cst.OCLFeatureCall call)
        Specified by:
        visitOclFeatureCall in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • visitDeferInitExpression

        public void visitDeferInitExpression​(net.ssehub.easy.varModel.cst.DeferInitExpression expression)
        Specified by:
        visitDeferInitExpression in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • visitMultiAndExpression

        public void visitMultiAndExpression​(net.ssehub.easy.varModel.cst.MultiAndExpression expression)
        Specified by:
        visitMultiAndExpression in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • visitLet

        public void visitLet​(net.ssehub.easy.varModel.cst.Let let)
        Specified by:
        visitLet in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • visitIfThen

        public void visitIfThen​(net.ssehub.easy.varModel.cst.IfThen ifThen)
        Specified by:
        visitIfThen in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • visitContainerOperationCall

        public void visitContainerOperationCall​(net.ssehub.easy.varModel.cst.ContainerOperationCall call)
        Specified by:
        visitContainerOperationCall in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • visitCompoundAccess

        public void visitCompoundAccess​(net.ssehub.easy.varModel.cst.CompoundAccess access)
        Specified by:
        visitCompoundAccess in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • visitUnresolvedExpression

        public void visitUnresolvedExpression​(net.ssehub.easy.varModel.cst.UnresolvedExpression expression)
        Specified by:
        visitUnresolvedExpression in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • visitCompoundInitializer

        public void visitCompoundInitializer​(net.ssehub.easy.varModel.cst.CompoundInitializer initializer)
        Specified by:
        visitCompoundInitializer in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • visitContainerInitializer

        public void visitContainerInitializer​(net.ssehub.easy.varModel.cst.ContainerInitializer initializer)
        Specified by:
        visitContainerInitializer in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • visitSelf

        public void visitSelf​(net.ssehub.easy.varModel.cst.Self self)
        Specified by:
        visitSelf in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor
      • visitBlockExpression

        public void visitBlockExpression​(net.ssehub.easy.varModel.cst.BlockExpression block)
        Specified by:
        visitBlockExpression in interface net.ssehub.easy.varModel.cst.IConstraintTreeVisitor