Class BreakStmt

  • All Implemented Interfaces:
    NodeWithRange<Node>, NodeWithTokenRange<Node>, Observable, Visitable, HasParentNode<Node>, Cloneable

    public class BreakStmt
    extends Statement

    The break statement

    Java 1.0-11

    Break has an optional label:
    break;
    break somewhere;
    The label is in the "value" property as a NameExpr.

    Java 12

    Break can now also have any expression, to be used in the switch-expression:
    break 123+456;
    break "more or less";
    The expression will be in the "value" property.

    Java 13

    The break statement has been reverted to what it was before Java 12, and break-with-value is now the YieldStatement.
    Author:
    Julio Vilmar Gesser
    See Also:
    SwitchExpr, YieldStmt
    • Constructor Detail

      • BreakStmt

        public BreakStmt()
      • BreakStmt

        public BreakStmt​(String label)
      • BreakStmt

        public BreakStmt​(SimpleName label)
      • BreakStmt

        public BreakStmt​(TokenRange tokenRange,
                         SimpleName label)
        This constructor is used by the parser and is considered private.
    • Method Detail

      • accept

        public <R,​A> R accept​(GenericVisitor<R,​A> v,
                                    A arg)
        Description copied from interface: Visitable
        Accept method for visitor support.
        Type Parameters:
        R - the type of the return value of the visitor
        A - the type the user argument passed to the visitor
        Parameters:
        v - the visitor implementation
        arg - the argument passed to the visitor (of type A)
        Returns:
        the result of the visit (of type R)
      • accept

        public <A> void accept​(VoidVisitor<A> v,
                               A arg)
        Description copied from interface: Visitable
        Accept method for visitor support.
        Type Parameters:
        A - the type the argument passed for the visitor
        Parameters:
        v - the visitor implementation
        arg - any value relevant for the visitor (of type A)
      • setLabel

        public BreakStmt setLabel​(SimpleName label)
        Sets the label
        Parameters:
        label - the label, can be null
        Returns:
        this, the BreakStmt
      • removeLabel

        public BreakStmt removeLabel()