A ClassNode should be created using the methods in ClassHelper. This ClassNode may be used to represent a class declaration or any other type. This class uses a proxy mechanism allowing to create a class for a plain name at AST creation time. In another phase of the compiler the real ClassNode for the plain name may be found. To avoid the need of exchanging this ClassNode with an instance of the correct ClassNode the correct ClassNode is set as redirect. Most method calls are then redirected to that ClassNode.
There are three types of ClassNodes:
Note
the redirect mechanism is only allowed for classes that are not primary ClassNodes. Typically this is done for classes created by name only. The redirect itself can be any type of ClassNode.
To describe generic type signature see getGenericsTypes() and
setGenericsTypes(GenericsType[]). These methods are not proxied,
they describe the type signature used at the point of declaration or the
type signatures provided by the class. If the type signatures provided
by the class are needed, then a call to redirect() will help.
org.codehaus.groovy.ast.ClassHelper
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| protected Class | |
| private CompileUnit | |
| private ClassNode | |
| private List | |
| public static final ClassNode[] | |
| private MethodNode | enclosingMethod
Tracks the enclosing method for local inner classes. |
| private Map | |
| private List | |
| private GenericsType[] | |
| protected List | |
| private ClassNode[] | |
| protected boolean | |
| private volatile boolean | |
| protected final Object | |
| private ClassNode. | |
| private List | |
| private MixinNode[] | |
| private int | |
| private ModuleNode | |
| private String | |
| private List | |
| private boolean | |
| private List | |
| private ClassNode | |
| private boolean | |
| private boolean | |
| private boolean | |
| public static final ClassNode | |
| private ClassNode | |
| private boolean | |
| public static final ClassNode | |
| private Map | transformInstances
The AST Transformations to be applied during compilation. |
| private boolean |
| Access | Constructor and Description |
|---|---|
| private | |
| private | |
| public | |
| public | ClassNode(String
the fully-qualified name of the class name, int the modifiers; see modifiers, ClassNode org.the base class; use "java.lang.Object" if no direct base class superClass)
|
| public | ClassNode(String
the fully-qualified name of the class name, int the modifiers; see modifiers, ClassNode org.the base class; use "java.lang.Object" if no direct base class superClass, ClassNode[] the interfaces for this class interfaces, MixinNode[] the mixins for this class mixins)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public ConstructorNode | |
| public void | |
| private void | |
| public FieldNode | |
| public void | |
| public FieldNode | |
| public void | |
| public void | |
| public MethodNode | |
| public void | |
| public void | addObjectInitializerStatements(Statement
the statement to be added statements)Adds a statement to the object initializer. |
| public void | |
| public PropertyNode | addProperty(String name, int modifiers, ClassNode type, Expression initialValueExpression, Statement getterBlock, Statement setterBlock)
|
| public void | |
| public MethodNode | |
| public void | |
| public GenericsType | |
| public boolean | Returns: true if this type declares that it implements any of the
given interfaces or if one of its interfaces extends directly/indirectly
any of the given interfacesthe class nodes for the interfaces classNodes)
|
| public boolean | Returns: true if this class declares that it implements the given
interface or if one of its interfaces extends directly/indirectly the interface
NOTE: Doesn't consider an interface to implement itself.
I think this is intended to be called on ClassNodes representing
classes, not interfaces.the class node for the interface classNode)
|
| public boolean | equals(Object
the reference object with which to compare. that)Overrides java. |
| private String | |
| public List | |
| public List | |
| public Set | |
| private void | |
| public List | |
| public List | |
| public CompileUnit | |
| public ClassNode | |
| public ConstructorNode | Returns: the constructor matching the given parameters ornull
|
| public List | |
| public FieldNode | Returns: the method matching the given name and parameters or nullthe name of the field of interest name)Finds a field matching the given name in this class. |
| public MethodNode | Returns: the method matching the given name and parameters or nullFinds a method matching the given name and parameters in this class. |
| public List | Returns: the method listThis method returns a list of all methods of the given name defined in the current class |
| public Map | |
| public MethodNode | |
| public FieldNode | |
| public Map | |
| public List | |
| public GenericsType[] | |
| public MethodNode | |
| public MethodNode | |
| public Iterator | |
| public ClassNode[] | |
| public MethodNode | |
| public List | |
| public List | Returns: the methods listThis method creates a list of all methods with this name of the current class and of all super classes |
| public MixinNode[] | |
| public int | |
| public ModuleNode | |
| public String | |
| public String | |
| public List | |
| private MethodNode | |
| public ClassNode | |
| public List | |
| public FieldNode | Returns: the field on the outer class ornull if this is not an inner class
|
| public PackageNode | |
| public String | |
| public ClassNode | |
| public List | |
| public PropertyNode | |
| public MethodNode | |
| public MethodNode | |
| public ClassNode | |
| public String | |
| private Map | |
| public Map | |
| public Class | Returns: the class this classnode relates to. May return null.Returns the concrete class this classnode relates to. |
| public ClassNode[] | |
| public ClassNode[] | |
| public String | |
| public ClassNode | |
| public ClassNode | |
| private static boolean | |
| private static boolean | |
| public boolean | |
| private static boolean | |
| public int | |
| public boolean | |
| public boolean | |
| public boolean | Returns: true if a matching method was foundthe name of the method of interest name, final Expression the arguments to match against arguments)Determines if the type has a possibly-matching instance method with the given name and arguments. |
| public boolean | Returns: true if a matching method was foundthe name of the method of interest name, final Expression the arguments to match against arguments)Checks if the given method has a possibly matching static method with the given name and arguments. |
| public boolean | |
| public boolean | Returns: true if this type implements any of the given interfacesthe class nodes for the interfaces classNodes)
|
| public boolean | Returns: true if this type implements the given interfacethe class node for the interface classNode)
|
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | Returns: true if this node is derived from the given ClassNodethe ClassNode of interest type)
|
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| private static boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | isStaticClass()
Is this class declared in a static method (such as a closure / inner class declared in a static method) |
| public boolean | Returns: true if node is public but had no explicit public modifierIndicates that this class has been "promoted" to public by Groovy when in fact there was no public modifier explicitly in the source code. |
| public boolean | |
| private void | lazyClassInit()
The complete class structure will be initialized only when really needed to avoid having too many objects during compilation. |
| public ClassNode | |
| protected boolean | Returns: true if the two arrays are of the same size and have the same contents
|
| public void | |
| public ClassNode | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| protected void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public String | |
| public void | setRedirect(ClassNode
the class to redirect to; if node)null the redirect is removedSets this instance as proxy for the given |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public String | |
| public String | |
| private String | |
| public MethodNode | |
| public void | |
| private void |