Package: org.codehaus.groovy.ast

## [Java] Class ModuleNode

- org.codehaus.groovy.ast.ModuleNode

- All Implemented Interfaces and Traits:
    org.objectweb.asm.Opcodes

      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

  Authors:
    Jochen Theodorou
    Paul King
    James Strachan

- - ### Constructor Summary

    Constructors
    Constructor and description
    `ModuleNode (SourceUnit context)`
    `ModuleNode (CompileUnit unit)`

  - ### Methods Summary

    Methods
    Type | Name and 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()` @return the underlying character stream description
    `ImportNode` | `getImport(String alias)` @param alias the name of interest
    `ClassNode` | `getImportType(String alias)` @param alias the name of interest
    `List<ImportNode>` | `getImports()`
    `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)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ASTNode` | `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getNodeMetaData, getText, putNodeMetaData, removeNodeMetaData, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setNodeMetaData, setSourcePosition, visit`
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Constructor Detail

    - #### public ModuleNode(SourceUnit context)

    - #### public ModuleNode(CompileUnit unit)

  - ### Method Detail

    - #### public void addClass(ClassNode node)

    - #### public void addImport(String alias, ClassNode type)

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

    - #### public void addMethod(MethodNode node)

    - #### public void addStarImport(String packageName)

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

    - #### public void addStatement(Statement node)

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

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

    - #### public void addStaticStarImport(String name, ClassNode type)

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

    - #### protected ClassNode createStatementsClass()

    - #### protected String extractClassFromFileDescription()

    - #### public List<ClassNode> getClasses()

    - #### public SourceUnit getContext()

    - #### public String getDescription()

      Returns:
        the underlying character stream description

    - #### 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

    - #### public ClassNode getImportType(String alias)

      Parameters:
        `alias` - the name of interest
      Returns:
        the class node for the given alias or null if none is available

    - #### public List<ImportNode> getImports()

    - #### public String getMainClassName()

    - #### public List<MethodNode> getMethods()

    - #### public PackageNode getPackage()

    - #### public String getPackageName()

    - #### public ClassNode getScriptClassDummy()

    - #### public List<ImportNode> getStarImports()

    - #### public BlockStatement getStatementBlock()

    - #### public Map<String, ImportNode> getStaticImports()

    - #### public Map<String, ImportNode> getStaticStarImports()

    - #### public CompileUnit getUnit()

    - #### public boolean hasImportsResolved()

    - #### public boolean hasPackage()

    - #### public boolean hasPackageName()

    - #### public boolean isEmpty()

    - #### public void setDescription(String description)

    - #### public void setImportsResolved(boolean importsResolved)

    - #### public void setPackage(PackageNode packageNode)

    - #### public void setPackageName(String packageName)

    - #### public void sortClasses()

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