Package: org.codehaus.groovy.ast

## [Java] Class ImportNode

- org.codehaus.groovy.ast.ImportNode

-     public class ImportNode
      extends AnnotatedNode

  Represents an import statement in Groovy source code, supporting single-type imports, wildcard imports, and static imports. Provides a unified representation for different import styles with methods to query import type and generate display text.

  See Also:
    ClassNode
    AnnotatedNode

- - ### Constructor Summary

    Constructors
    Constructor and description
    `ImportNode(ClassNode type, String alias)` Creates an import for a single type (e.g., `import pack.Type` or `import pack.Type as Alias`).
    `ImportNode(String packageName)` Creates an import for all types in a package (e.g., `import pack.*`).
    `ImportNode(ClassNode type)` Creates a static wildcard import for all static members of a type (e.g., `import static pack.Type.*`).
    `ImportNode(ClassNode type, String fieldName, String alias)` Creates a static import for a specific field or method of a type (e.g., `import static pack.Type.name` or `import static pack.Type.name as alias`).

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public boolean` | `equals(Object that)`
    `` | `public String` | `getAlias()` Returns the alias name for this import, if specified.
    `` | `public String` | `getClassName()` Returns the fully qualified class name of the imported type.
    `` | `public String` | `getFieldName()` Returns the name of the static field or method being imported via static import.
    `` | `public String` | `getPackageName()` Returns the package name for a wildcard import, or the package containing the imported type or static member.
    `` | `public String` | `getText()` Generates the text representation of this import statement as it would appear in source code.
    `` | `public ClassNode` | `getType()` Returns the ClassNode being imported or providing static members.
    `` | `public int` | `hashCode()`
    `` | `public boolean` | `isStar()`
    `` | `public boolean` | `isStatic()`
    `` | `public void` | `setType(ClassNode type)` Updates the ClassNode being imported.
    `` | `public void` | `visit(GroovyCodeVisitor visitor)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `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 ImportNode(ClassNode type, String alias)

      Creates an import for a single type (e.g., `import pack.Type` or `import pack.Type as Alias`).

      throws:
        NullPointerException if type is null
      Parameters:
        `type` - the ClassNode being imported (never null)
        `alias` - an optional alias name, or null if no alias is specified

    - #### public ImportNode(String packageName)

      Creates an import for all types in a package (e.g., `import pack.*`).

      throws:
        NullPointerException if packageName is null
      Parameters:
        `packageName` - the fully qualified package name (never null)

    - #### public ImportNode(ClassNode type)

      Creates a static wildcard import for all static members of a type (e.g., `import static pack.Type.*`).

      throws:
        NullPointerException if type is null
      Parameters:
        `type` - the ClassNode whose static members are imported (never null)

    - #### public ImportNode(ClassNode type, String fieldName, String alias)

      Creates a static import for a specific field or method of a type (e.g., `import static pack.Type.name` or `import static pack.Type.name as alias`).

      throws:
        NullPointerException if type or fieldName is null
      Parameters:
        `type` - the ClassNode containing the static member (never null)
        `fieldName` - the name of the static field or method being imported (never null)
        `alias` - an optional alias name, or null if no alias is specified

  - ### Method Detail

    - #### public boolean equals(Object that)

    - #### public String getAlias()

      Returns the alias name for this import, if specified.

      Returns:
        the alias, or null if no alias is provided

    - #### public String getClassName()

      Returns the fully qualified class name of the imported type.

      Returns:
        the class name, or null if this import refers to a package

    - #### public String getFieldName()

      Returns the name of the static field or method being imported via static import.

      Returns:
        the field name, or null if this is not a static field/method import

    - #### public String getPackageName()

      Returns the package name for a wildcard import, or the package containing the imported type or static member.

      Returns:
        the package name, or null if this import references a specific type

    - #### public String getText()

      Generates the text representation of this import statement as it would appear in source code. For example: "import java.util.List", "import static java.util.Collections.*", etc.

      Returns:
        the text representation of this import

    - #### public ClassNode getType()

      Returns the ClassNode being imported or providing static members.

      Returns:
        the imported type, or null if this is a package-level wildcard import

    - #### public int hashCode()

    - #### public boolean isStar()

    - #### public boolean isStatic()

    - #### public void setType(ClassNode type)

      Updates the ClassNode being imported. This may be used during compilation phases to replace placeholder types with resolved types.

      throws:
        NullPointerException if type is null
      Parameters:
        `type` - the new ClassNode (never null)

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