Class ClassGeneratorImpl
- java.lang.Object
-
- org.glassfish.pfl.dynamic.codegen.impl.ClassInfoBase
-
- org.glassfish.pfl.dynamic.codegen.impl.ClassGeneratorImpl
-
- All Implemented Interfaces:
AttributedObject,Node,ClassGenerator,ClassInfo
public final class ClassGeneratorImpl extends ClassInfoBase implements ClassGenerator, Node
Class used to generate a description of a class or interface. An interface is an abstract class, all of whose methods are abstract. Interfaces do not have a super class, an initializer, or constructors. Interfaces also do not have variables.Note: the hashCode of a ClassGeneratorImpl changes whenever a method, constructor, or field is added, so do not put ClassGenerators into sets or maps unless they are fully populated.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<MethodGenerator>constructorsprivate java.util.List<FieldGenerator>fieldsprivate BlockStatementinitializerprivate java.util.List<MethodGenerator>methodsprivate NodenodeImpl
-
Constructor Summary
Constructors Constructor Description ClassGeneratorImpl(int modifiers, java.lang.String name, java.util.List<Type> impls)Construct a ClassGeneratorImpl representing an interface.ClassGeneratorImpl(int modifiers, java.lang.String name, Type superType, java.util.List<Type> impls)Construct a ClassGeneratorImpl representing a class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(Visitor visitor)Accept the visitor and allow it to perform actions on this Node.FieldGeneratoraddField(int modifiers, Type type, java.lang.String name)java.util.List<java.lang.Object>attributes()Internal method for dynamic attribute support.java.util.Set<MethodInfo>constructorInfo()java.util.List<MethodGenerator>constructors()<T extends Node>
Tcopy(java.lang.Class<T> cls)Make a deep copy of this node.<T extends Node>
Tcopy(Node newParent, java.lang.Class<T> cls)Copy setting a new parent in the result.java.util.List<FieldGenerator>fields()java.lang.Objectget(int index)Internal method for dynamic attribute support.<T extends Node>
TgetAncestor(java.lang.Class<T> type)Return the first ancestor of this node of the given type, if any.intid()Return the unique ID of this node.BlockStatementinitializer()voidmethodComplete(MethodGenerator mg)java.util.List<MethodGenerator>methods()Nodeparent()Return the Node that contains (and created) this Node.voidparent(Node node)Set the parent to a new value.voidset(int index, java.lang.Object obj)Internal method for dynamic attribute support.MethodGeneratorstartConstructor(int modifiers, java.util.List<Type> exceptions)MethodGeneratorstartMethod(int modifiers, Type rtype, java.lang.String name, java.util.List<Type> exceptions)-
Methods inherited from class org.glassfish.pfl.dynamic.codegen.impl.ClassInfoBase
addConstructorInfo, addFieldInfo, addMethodInfo, className, equals, fieldInfo, findConstructorInfo, findFieldInfo, findMethodInfo, hashCode, impls, initializeClass, initializeInterface, isInterface, isSubclass, methodInfoByName, modifiers, name, pkgName, superType, thisType, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.glassfish.pfl.dynamic.codegen.spi.ClassGenerator
name
-
Methods inherited from interface org.glassfish.pfl.dynamic.codegen.spi.ClassInfo
className, fieldInfo, findConstructorInfo, findFieldInfo, findMethodInfo, impls, isInterface, isSubclass, methodInfoByName, modifiers, pkgName, superType, thisType
-
-
-
-
Field Detail
-
nodeImpl
private Node nodeImpl
-
initializer
private BlockStatement initializer
-
methods
private java.util.List<MethodGenerator> methods
-
constructors
private java.util.List<MethodGenerator> constructors
-
fields
private java.util.List<FieldGenerator> fields
-
-
Constructor Detail
-
ClassGeneratorImpl
ClassGeneratorImpl(int modifiers, java.lang.String name, java.util.List<Type> impls)Construct a ClassGeneratorImpl representing an interface.
-
-
Method Detail
-
parent
public Node parent()
Description copied from interface:NodeReturn the Node that contains (and created) this Node.
-
id
public int id()
Description copied from interface:NodeReturn the unique ID of this node. This starts at 1 and is incremented for each new Node that is created.
-
parent
public void parent(Node node)
Description copied from interface:NodeSet the parent to a new value. Should only be called inside NodeBase.
-
getAncestor
public <T extends Node> T getAncestor(java.lang.Class<T> type)
Description copied from interface:NodeReturn the first ancestor of this node of the given type, if any. Throws IllegalArgumentException if not found.- Specified by:
getAncestorin interfaceNode
-
copy
public <T extends Node> T copy(java.lang.Class<T> cls)
Description copied from interface:NodeMake a deep copy of this node. If nn = n.copy(), then n.parent() == nn.parent(), which also means that the parent is NOT copied.
-
copy
public <T extends Node> T copy(Node newParent, java.lang.Class<T> cls)
Description copied from interface:NodeCopy setting a new parent in the result.
-
get
public java.lang.Object get(int index)
Description copied from interface:AttributedObjectInternal method for dynamic attribute support. Return the value of the attribute at index. If the attribute at index is not set, set it to the default value and return the default.- Specified by:
getin interfaceAttributedObject
-
set
public void set(int index, java.lang.Object obj)Description copied from interface:AttributedObjectInternal method for dynamic attribute support. Set the attribute at index to obj.- Specified by:
setin interfaceAttributedObject
-
attributes
public java.util.List<java.lang.Object> attributes()
Description copied from interface:AttributedObjectInternal method for dynamic attribute support. Return all attributes for this node (may be null).- Specified by:
attributesin interfaceAttributedObject
-
initializer
public BlockStatement initializer()
-
fields
public java.util.List<FieldGenerator> fields()
-
methods
public java.util.List<MethodGenerator> methods()
-
constructors
public java.util.List<MethodGenerator> constructors()
-
constructorInfo
public java.util.Set<MethodInfo> constructorInfo()
- Specified by:
constructorInfoin interfaceClassInfo- Overrides:
constructorInfoin classClassInfoBase
-
startMethod
public MethodGenerator startMethod(int modifiers, Type rtype, java.lang.String name, java.util.List<Type> exceptions)
-
startConstructor
public MethodGenerator startConstructor(int modifiers, java.util.List<Type> exceptions)
-
methodComplete
public void methodComplete(MethodGenerator mg)
-
addField
public FieldGenerator addField(int modifiers, Type type, java.lang.String name)
-
-