ModuleNode (Groovy 4.0.15)
Description: declaration: package: org.codehaus.groovy.ast, class: ModuleNode

Package org.codehaus.groovy.ast

# Class ModuleNode

java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.ModuleNode

All Implemented Interfaces:
  `NodeMetaDataHandler`

public class ModuleNode extends ASTNode
Represents a module, which consists typically of a class declaration but could include some imports, some statements and multiple classes intermixed with statements like scripts in Python or Ruby

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ModuleNode(CompileUnit unit)`
  `ModuleNode(SourceUnit context)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addClass(ClassNode node)`
  `void`
  `addImport(String alias, ClassNode type)`
  `void`
  `addImport(String alias, ClassNode type, List<AnnotationNode> annotations)`
  `void`
  `addMethod(MethodNode node)`
  `void`
  `addStarImport(String packageName)`
  `void`
  `addStarImport(String packageName, List<AnnotationNode> annotations)`
  `void`
  `addStatement(Statement node)`
  `void`
  `addStaticImport(ClassNode type, String fieldName, String alias)`
  `void`
  `addStaticImport(ClassNode type, String fieldName, String alias, List<AnnotationNode> annotations)`
  `void`
  `addStaticStarImport(String name, ClassNode type)`
  `void`
  `addStaticStarImport(String name, ClassNode type, List<AnnotationNode> annotations)`
  `protected ClassNode`
  `createStatementsClass()`
  `protected String`
  `extractClassFromFileDescription()`
  `List<ClassNode>`
  `getClasses()`
  `SourceUnit`
  `getContext()`
  `String`
  `getDescription()`
  `ImportNode`
  `getImport(String alias)`
  `List<ImportNode>`
  `getImports()`
  `ClassNode`
  `getImportType(String alias)`
  `String`
  `getMainClassName()`
  `List<MethodNode>`
  `getMethods()`
  `PackageNode`
  `getPackage()`
  `String`
  `getPackageName()`
  `ClassNode`
  `getScriptClassDummy()`
  `List<ImportNode>`
  `getStarImports()`
  `BlockStatement`
  `getStatementBlock()`
  `Map<String,ImportNode>`
  `getStaticImports()`
  `Map<String,ImportNode>`
  `getStaticStarImports()`
  `CompileUnit`
  `getUnit()`
  `boolean`
  `hasImportsResolved()`
  `boolean`
  `hasPackage()`
  `boolean`
  `hasPackageName()`
  `boolean`
  `isEmpty()`
  `void`
  `setDescription(String description)`
  `void`
  `setImportsResolved(boolean importsResolved)`
  `void`
  `setPackage(PackageNode packageNode)`
  `void`
  `setPackageName(String packageName)`
  `void`
  `sortClasses()`
  `void`
  `visit(GroovyCodeVisitor visitor)`

  ### Methods inherited from class org.codehaus.groovy.ast.ASTNode

  `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler

  `copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, putNodeMetaData, removeNodeMetaData, setNodeMetaData`

- ## Constructor Details

  - ### ModuleNode

    public ModuleNode(SourceUnit context)

  - ### ModuleNode

    public ModuleNode(CompileUnit unit)

- ## Method Details

  - ### getClasses

    public List<ClassNode> getClasses()

  - ### getMethods

    public List<MethodNode> getMethods()
    Returns:
      the module's methods

  - ### getImports

    public List<ImportNode> getImports()
    Returns:
      a copy of the module's imports

  - ### getStarImports

    public List<ImportNode> getStarImports()
    Returns:
      the module's star imports

  - ### getStaticImports

    public Map<String,ImportNode> getStaticImports()
    Returns:
      the module's static imports

  - ### getStaticStarImports

    public Map<String,ImportNode> getStaticStarImports()
    Returns:
      the module's static star imports

  - ### getImportType

    public ClassNode getImportType(String alias)
    Parameters:
      `alias` - the name of interest
    Returns:
      the import type for the given alias or null if none is available

  - ### getImport

    public ImportNode getImport(String alias)
    Parameters:
      `alias` - the name of interest
    Returns:
      the import node for the given alias or null if none is available

  - ### addImport

    public void addImport(String alias, ClassNode type)

  - ### addImport

    public void addImport(String alias, ClassNode type, List<AnnotationNode> annotations)

  - ### addStarImport

    public void addStarImport(String packageName)

  - ### addStarImport

    public void addStarImport(String packageName, List<AnnotationNode> annotations)

  - ### addStaticImport

    public void addStaticImport(ClassNode type, String fieldName, String alias)

  - ### addStaticImport

    public void addStaticImport(ClassNode type, String fieldName, String alias, List<AnnotationNode> annotations)

  - ### addStaticStarImport

    public void addStaticStarImport(String name, ClassNode type)

  - ### addStaticStarImport

    public void addStaticStarImport(String name, ClassNode type, List<AnnotationNode> annotations)

  - ### addStatement

    public void addStatement(Statement node)

  - ### addClass

    public void addClass(ClassNode node)

  - ### addMethod

    public void addMethod(MethodNode node)

  - ### visit

    public void visit(GroovyCodeVisitor visitor)
    Overrides:
      `visit` in class `ASTNode`

  - ### getPackageName

    public String getPackageName()

  - ### getPackage

    public PackageNode getPackage()

  - ### hasPackage

    public boolean hasPackage()

  - ### setPackage

    public void setPackage(PackageNode packageNode)

  - ### hasPackageName

    public boolean hasPackageName()

  - ### setPackageName

    public void setPackageName(String packageName)

  - ### getDescription

    public String getDescription()
    Returns:
      the underlying character stream description

  - ### setDescription

    public void setDescription(String description)

  - ### getUnit

    public CompileUnit getUnit()

  - ### getContext

    public SourceUnit getContext()

  - ### getScriptClassDummy

    public ClassNode getScriptClassDummy()

  - ### createStatementsClass

    protected ClassNode createStatementsClass()

  - ### extractClassFromFileDescription

    protected String extractClassFromFileDescription()

  - ### isEmpty

    public boolean isEmpty()

  - ### sortClasses

    public void sortClasses()

  - ### hasImportsResolved

    public boolean hasImportsResolved()

  - ### setImportsResolved

    public void setImportsResolved(boolean importsResolved)

  - ### getMainClassName

    public String getMainClassName()

  - ### getStatementBlock

    public BlockStatement getStatementBlock()