Class EnhancedForStatement


public class EnhancedForStatement extends Statement
Enhanced For statement AST node type (added in JLS3 API).
 EnhancedForStatement:
    for ( FormalParameter : Expression )
                        Statement
 

The FormalParameter is represented by a SingleVariableDeclaration (without an initializer).

Since:
3.1
Restriction:
This class is not intended to be instantiated by clients.
  • Field Details

  • Method Details

    • propertyDescriptors

      public static List propertyDescriptors(int apiLevel)
      Returns a list of structural property descriptors for this node type. Clients must not modify the result.
      Parameters:
      apiLevel - the API level; one of the AST.JLS* constants
      Returns:
      a list of property descriptors (element type: StructuralPropertyDescriptor)
    • getParameter

      public SingleVariableDeclaration getParameter()
      Returns the formal parameter in this enhanced for statement.
      Returns:
      the parameter
    • setParameter

      public void setParameter(SingleVariableDeclaration parameter)
      Sets the formal parameter in this enhanced for statement.
      Parameters:
      parameter - the new parameter
      Throws:
      IllegalArgumentException - if:
      • the node belongs to a different AST
      • the node already has a parent
    • getExpression

      public Expression getExpression()
      Returns the expression of this enhanced for statement.
      Returns:
      the expression node
    • setExpression

      public void setExpression(Expression expression)
      Sets the expression of this enhanced for statement.
      Parameters:
      expression - the new expression node
      Throws:
      IllegalArgumentException - if:
      • the node belongs to a different AST
      • the node already has a parent
      • a cycle in would be created
    • getBody

      public Statement getBody()
      Returns the body of this enchanced for statement.
      Returns:
      the body statement node
    • setBody

      public void setBody(Statement statement)
      Sets the body of this enhanced for statement.
      Parameters:
      statement - the body statement node
      Throws:
      IllegalArgumentException - if:
      • the node belongs to a different AST
      • the node already has a parent
      • a cycle in would be created