Package: org.codehaus.groovy.ast.expr

## [Java] Class ArrayExpression

- org.codehaus.groovy.ast.expr.ArrayExpression

-     public class ArrayExpression
      extends Expression

  Represents an array literal or array construction expression. Supports both fixed-size array construction (e.g., `new String[3]` or `new Integer[2][3]`) and array initialization with explicit elements (e.g., `new String[] { "foo", "bar" }`). The expression may be either an initializer-based array or a size-based array, but not both.

  See Also:
    ClassNode for array type representation
    ConstantExpression for element expressions

- - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class Expression` | `EMPTY_ARRAY`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `ArrayExpression(ClassNode elementType, List<Expression> initExpressions, List<Expression> sizeExpressions)` Constructs an array expression with either size expressions or initializer expressions.
    `ArrayExpression(ClassNode elementType, List<Expression> initExpressions)` Creates an array using an initializer list of expressions corresponding to array elements.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `addExpression(Expression initExpression)` Adds an element to the initializer expressions.
    `` | `public ClassNode` | `getElementType()` Returns the base element type of the array (before array dimensions are applied).
    `` | `public Expression` | `getExpression(int i)` Returns the initializer expression at the specified index.
    `` | `public List<Expression>` | `getExpressions()` Returns the list of initializer expressions for array elements.
    `` | `public List<Expression>` | `getSizeExpression()` Returns the size expressions for each dimension of the array.
    `` | `public String` | `getText()`
    `` | `public boolean` | `hasInitializer()` Indicates whether this array is defined by an explicit initializer or by size expressions.
    `` | `public boolean` | `isDynamic()`
    `` | `public String` | `toString()`
    `` | `public Expression` | `transformExpression(ExpressionTransformer transformer)`
    `` | `public void` | `visit(GroovyCodeVisitor visitor)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Expression` | `getType, setType, transformExpression, transformExpressions, transformExpressions`
    `class AnnotatedNode` | `addAnnotation, addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic`
    `class ASTNode` | `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit`

- - ### Constructor Detail

    - #### public ArrayExpression(ClassNode elementType, List<Expression> initExpressions, List<Expression> sizeExpressions)

      Constructs an array expression with either size expressions or initializer expressions.

      throws:
        IllegalArgumentException if both initExpressions and sizeExpressions are provided or both are null/empty
      throws:
        IllegalArgumentException if any initializer is not an Expression
      Parameters:
        `elementType` - the base element type of the array (non-null)
        `initExpressions` - the list of initializer expressions for array elements, or null for size-based construction
        `sizeExpressions` - the list of size expressions (one per dimension) for fixed-size arrays, or null for initializer-based construction

    - #### public ArrayExpression(ClassNode elementType, List<Expression> initExpressions)

      Creates an array using an initializer list of expressions corresponding to array elements.

      Parameters:
        `elementType` - the base element type of the array (non-null)
        `initExpressions` - the list of initializer expressions for array elements (non-null)

  - ### Method Detail

    - #### public void addExpression(Expression initExpression)

      Adds an element to the initializer expressions.

      Parameters:
        `initExpression` - the expression to add (non-null)

    - #### public ClassNode getElementType()

      Returns the base element type of the array (before array dimensions are applied).

      Returns:
        the element type

    - #### public Expression getExpression(int i)

      Returns the initializer expression at the specified index.

      throws:
        IndexOutOfBoundsException if the index is out of range
      Parameters:
        `i` - the index of the element
      Returns:
        the expression at the specified index

    - #### public List<Expression> getExpressions()

      Returns the list of initializer expressions for array elements.

      Returns:
        a list of initializer expressions (non-null but may be empty for size-based arrays)

    - #### public List<Expression> getSizeExpression()

      Returns the size expressions for each dimension of the array.

      Returns:
        a list with one expression per array dimension (non-null for size-based arrays, null for initializer-based)

    - #### public String getText()

    - #### public boolean hasInitializer()

      Indicates whether this array is defined by an explicit initializer or by size expressions.

      Returns:
        true if the array has an explicit initializer, false if defined by size expressions

    - #### public boolean isDynamic()

    - #### public String toString()

    - #### public Expression transformExpression(ExpressionTransformer transformer)

    - #### public void visit(GroovyCodeVisitor visitor)