net.sourceforge.pmd.lang.java.ast.ASTArrayInitializer Maven / Gradle / Ivy
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.ast;
import java.util.Iterator;
/**
* An array initializer. May occur in two syntactic contexts:
*
* - The right-hand side of a {@linkplain ASTVariableDeclarator variable declarator}
*
- Inside an {@linkplain ASTArrayAllocation array allocation expression}
*
*
*
*
* ArrayInitializer ::= "{" ( "," )? "}"
* | "{" {@link ASTExpression Expression} ( "," {@link ASTExpression Expression} )* ( "," )? "}"
*
*
*
*/
public final class ASTArrayInitializer extends AbstractJavaExpr implements ASTExpression, Iterable {
ASTArrayInitializer(int id) {
super(id);
}
@Override
protected R acceptVisitor(JavaVisitor super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
/**
* Return the number of elements.
*/
public int length() {
return getNumChildren();
}
@Override
public Iterator iterator() {
return children(ASTExpression.class).iterator();
}
}