Package: org.codehaus.groovy.ast

## [Java] Class ModuleNode

- org.codehaus.groovy.ast.ModuleNode

-     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 and description
    `ModuleNode(SourceUnit context)`
    `ModuleNode(CompileUnit unit)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `addClass(ClassNode node)`
    `` | `public void` | `addImport(String name, ClassNode type)`
    `` | `public void` | `addImport(String name, 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 memberName, String simpleName)`
    `` | `public void` | `addStaticImport(ClassNode type, String memberName, String simpleName, 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
    `` | `public ClassNode` | `getImportType(String alias)` Parameters: `alias` - the name of interest
    `` | `public List<ImportNode>` | `getImports()` Returns: a copy of the module's imports
    `` | `public String` | `getMainClassName()`
    `` | `public List<MethodNode>` | `getMethods()` Returns: the module's methods
    `` | `public ClassNode` | `getOuterClass()`
    `` | `public PackageNode` | `getPackage()`
    `` | `public String` | `getPackageName()`
    `` | `public ClassNode` | `getScriptClassDummy()`
    `` | `public List<ImportNode>` | `getStarImports()` Returns: the module's star imports
    `` | `public BlockStatement` | `getStatementBlock()`
    `` | `public Map<String, ImportNode>` | `getStaticImports()` Returns: the module's static imports
    `` | `public Map<String, ImportNode>` | `getStaticStarImports()` Returns: the module's static star imports
    `` | `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)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ASTNode` | `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit`

- - ### Constructor Detail

    - #### public ModuleNode(SourceUnit context)

    - #### public ModuleNode(CompileUnit unit)

  - ### Method Detail

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

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

    - #### public void addImport(String name, 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 memberName, String simpleName)

    - #### public void addStaticImport(ClassNode type, String memberName, String simpleName, 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 import type for the given alias or null if none is available

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

      Returns:
        a copy of the module's imports

    - #### public String getMainClassName()

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

      Returns:
        the module's methods

    - #### @Override
      public ClassNode getOuterClass()

    - #### public PackageNode getPackage()

    - #### public String getPackageName()

    - #### public ClassNode getScriptClassDummy()

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

      Returns:
        the module's star imports

    - #### public BlockStatement getStatementBlock()

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

      Returns:
        the module's static imports

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

      Returns:
        the module's static star imports

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

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