Class ZestConditional

    • Constructor Detail

      • ZestConditional

        public ZestConditional()
        Instantiates a new zest conditional.
      • ZestConditional

        public ZestConditional​(ZestExpressionElement rootExp)
        Instantiates a new zest conditional.
        Parameters:
        rootExp - the root exp
      • ZestConditional

        public ZestConditional​(int index)
        Instantiates a new zest conditional with a statement index.
        Parameters:
        index - the index
      • ZestConditional

        public ZestConditional​(int index,
                               ZestExpressionElement rootExp)
        Instantiates a new zest conditional.
        Parameters:
        index - the index
        rootExp - the root exp
    • Method Detail

      • addIf

        public void addIf​(ZestStatement req)
        Adds an if statement.
        Parameters:
        req - the Statement to add as If
      • addIf

        public void addIf​(int index,
                          ZestStatement req)
        Adds an if.
        Parameters:
        index - the index of the new statement in the if list
        req - the statement to add as If at position index
      • moveIf

        public void moveIf​(int index,
                           ZestStatement req)
        Moves if.
        Parameters:
        index - the new index
        req - the statement to move
      • removeIf

        public void removeIf​(ZestStatement req)
        Removes an if.
        Parameters:
        req - the if statement to remove
      • removeIfStatement

        public void removeIfStatement​(int index)
        Removes an if statement.
        Parameters:
        index - the index of the statement to remove
      • getIfStatement

        public ZestStatement getIfStatement​(int index)
        Gets the if statement.
        Parameters:
        index - the index
        Returns:
        the if statement at index
        Throws:
        IndexOutOfBoundsException - the index out of bounds exception
      • getIfStatements

        public List<ZestStatement> getIfStatements()
        Gets the if statements list.
        Returns:
        the if statements list
      • addElse

        public void addElse​(ZestStatement req)
        Adds an else.
        Parameters:
        req - the statement to add as else
      • addElse

        public void addElse​(int index,
                            ZestStatement req)
        Adds an else.
        Parameters:
        index - the index where to add the else statement
        req - the new else statement
      • moveElse

        public void moveElse​(int index,
                             ZestStatement req)
        Moves an else.
        Parameters:
        index - the destination of the else statement
        req - the else statement to move
      • removeElse

        public void removeElse​(ZestStatement req)
        Removes an else.
        Parameters:
        req - the else statement to remove
      • removeElseStatement

        public void removeElseStatement​(int index)
        Removes an else statement.
        Parameters:
        index - the index of the else statement to remove
      • getElseStatement

        public ZestStatement getElseStatement​(int index)
        Gets the else statement in a given index.
        Parameters:
        index - the index
        Returns:
        the else statement at the given index
        Throws:
        IndexOutOfBoundsException - the index out of bounds exception
      • getElseStatements

        public List<ZestStatement> getElseStatements()
        Gets the else statements list.
        Returns:
        the else statements list
      • isSameSubclass

        public boolean isSameSubclass​(ZestElement ze)
        Description copied from class: ZestElement
        Checks if is same subclass.
        Overrides:
        isSameSubclass in class ZestStatement
        Parameters:
        ze - the ze
        Returns:
        true, if is same subclass
      • getVariableNames

        public Set<String> getVariableNames()
        Description copied from interface: ZestContainer
        Returns all of the variable names defined by this staement and its children.
        Specified by:
        getVariableNames in interface ZestContainer
        Returns:
        the tokens
      • isTrue

        public boolean isTrue​(ZestRuntime runtime)
        Checks if the conditional is true.
        Parameters:
        runtime - the runtime
        Returns:
        true, if the condition is true
      • getRootExpression

        public ZestExpressionElement getRootExpression()
        Gets the root expression.
        Returns:
        the root expression
      • setRootExpression

        public ZestExpressionElement setRootExpression​(ZestExpressionElement new_root)
        Sets the root expression.
        Parameters:
        new_root - the new_root expression
        Returns:
        the zest previous root expression
      • isPassive

        public boolean isPassive()
        Description copied from class: ZestStatement
        Checks if is passive.
        Specified by:
        isPassive in class ZestStatement
        Returns:
        true, if is passive