Top Description Fields Constructors Methods
com.sun.codemodel

public Class JDefinedClass

extends JClass
implements JDeclaration, JClassContainer, JGenerifiable, JAnnotatable, JDocCommentable
Class Inheritance
All Implemented Interfaces
com.sun.codemodel.JDocCommentable, com.sun.codemodel.JAnnotatable, com.sun.codemodel.JGenerifiable, com.sun.codemodel.JClassContainer, com.sun.codemodel.JDeclaration
Known Direct Subclasses
com.sun.codemodel.JAnonymousClass
Imports
java.lang.annotation.Annotation, java.util.ArrayList, .Collection, .Collections, .Iterator, .LinkedHashMap, .List, .Map, .Set, .TreeMap, .TreeSet

A generated Java class/interface/enum/....

This class models a declaration, and since a declaration can be always used as a reference, it inherits JClass.

Where to go from here?

You'd want to generate fields and methods on a class. See method(int, JType, String) and field(int, JType, String).

Field Summary

Modifier and TypeField and Description
private List<JAnnotationUse>
annotations

Annotations on this variable.

private Map<String, JDefinedClass>
classes

Nested classes as a map from name to JDefinedClass.

private final ClassType
classType

Default value is class or interface or annotationTypeDeclaration or enum

private final List<JMethod>
constructors

Set of constructors for this class, if any

private String
directBlock

String that will be put directly inside the generated code.

private final Map<String, JEnumConstant>
enumConstantsByName

Set of enum constants that are keyed by names.

pack-priv final Map<String, JFieldVar>
fields

Fields keyed by their names.

private final JGenerifiableImpl
generifiable

Helper class to implement JGenerifiable.

private boolean
hideFile

Flag that controls whether this class should be really generated or not.

private JBlock
init

Static initializer, if this class has one

private JBlock
instanceInit

Instance initializer, if this class has one

private final Set<JClass>
interfaces

List of interfaces that this class implements

private JDocComment
jdoc

class javadoc

public Object
metadata

Client-app spcific metadata associated with this user-created class.

private final List<JMethod>
methods

Set of methods that are members of this class

private JMods
mods

Modifiers for the class declaration

private String
name

Name of this class.

private JClassContainer
outer

If this is a package-member class, this is JPackage.

private JClass
superClass

Name of the super class of this class.

Inherited from com.sun.codemodel.JClass:
EMPTY_ARRAY

Constructor Summary

AccessConstructor and Description
pack-priv
JDefinedClass(JClassContainer parent, int mods, String name, ClassType classTypeval)

pack-priv
JDefinedClass(JCodeModel owner, int mods, String name)

Constructor for creating anonymous inner class.

private
JDefinedClass(int mods, String name, JClassContainer parent, JCodeModel owner)

private
JDefinedClass(int
Modifiers for this class declaration
mods
,
String
Name of this class
name
,
JClassContainer parent, JCodeModel owner, ClassType classTypeVal)

JClass constructor

Method Summary

Modifier and TypeMethod and Description
public JDefinedClass

Returns:

newly created Annotation Type Declaration
_annotationTypeDeclaration
(String
Name of the annotation Type declaration to be added to this package
name
)

Implements com.sun.codemodel.JClassContainer._annotationTypeDeclaration.

Add an annotationType Declaration to this package

public JDefinedClass

Returns:

Newly generated class
_class
(int
Modifiers for this class declaration
mods
,
String
Name of class to be added to this package
name
)

Implements com.sun.codemodel.JClassContainer._class.

Add a new nested class to this class.

public JDefinedClass
_class(int mods, String name, boolean isInterface)

Implements com.sun.codemodel.JClassContainer._class.

Deprecated

Create a new class or a new interface.

public JDefinedClass
_class(int mods, String name, ClassType classTypeVal)

Implements com.sun.codemodel.JClassContainer._class.

Creates a new class/enum/interface/annotation.

public JDefinedClass
_class(String name)

Implements com.sun.codemodel.JClassContainer._class.

Add a new public nested class to this class.

public JDefinedClass

Returns:

newly created Enum
_enum
(String
Name of the enum to be added to this package
name
)

Implements com.sun.codemodel.JClassContainer._enum.

Add a public enum to this package

public JDefinedClass

Returns:

newly created Enum
_enum
(int
Modifiers for this enum declaration
mods
,
String
Name of the enum to be added to this package
name
)

Add a public enum to this package

public JDefinedClass

Returns:

This class
_extends
(JClass
Superclass for this class
superClass
)

This class extends the specifed class.

public JDefinedClass
_extends(Class<?> superClass)

public JClass
_extends()

Implements abstract com.sun.codemodel.JClass._extends.

Returns the class extended by this class.

public JDefinedClass

Returns:

This class
_implements
(JClass
Interface that this class implements
iface
)

This class implements the specifed interface.

public JDefinedClass
_implements(Class<?> iface)

public Iterator<JClass>
_implements()

Implements abstract com.sun.codemodel.JClass._implements.

Returns an iterator that walks the nested classes defined in this class.

public JDefinedClass

Returns:

Newly generated interface
_interface
(int
Modifiers for this interface declaration
mods
,
String
Name of interface to be added to this package
name
)

Implements com.sun.codemodel.JClassContainer._interface.

Add an interface to this package.

public JDefinedClass
_interface(String name)

Implements com.sun.codemodel.JClassContainer._interface.

Adds a public interface to this package.

public final JPackage
_package()

Implements abstract com.sun.codemodel.JClass._package.

Gets the package to which this class belongs.

public JAnnotationUse
annotate(Class<? extends Annotation>
The annotation class to annotate the class with
clazz
)

Implements com.sun.codemodel.JAnnotatable.annotate.

Adding ability to annotate a class

public JAnnotationUse
annotate(JClass
The annotation class to annotate the class with
clazz
)

Implements com.sun.codemodel.JAnnotatable.annotate.

Adding ability to annotate a class

public <W extends JAnnotationWriter<? extends Annotation>> W
annotate2(Class<W> clazz)

Implements com.sun.codemodel.JAnnotatable.annotate2.

Adds an annotation to this program element and returns a type-safe writer to fill in the values of such annotations.

public Collection<JAnnotationUse>
annotations()

Implements com.sun.codemodel.JAnnotatable.annotations.

Read-only live view of all annotations on this

public String
binaryName()

Overrides com.sun.codemodel.JType.binaryName.

Gets the binary name of the type.

public final Iterator<JDefinedClass>
classes()

Implements com.sun.codemodel.JClassContainer.classes.

Returns an iterator that walks the nested classes defined in this class.

public JMethod
constructor(int
Modifiers for this constructor
mods
)

Adds a constructor to this class.

public Iterator<JMethod>
constructors()

Returns an iterator that walks the constructors defined in this class.

public void
protected void
declareBody(JFormatter f)

prints the body of a class.

public void
direct(String string)

Places the given string directly inside the generated class.

public JEnumConstant

Returns:

The generated type-safe enum constant.
enumConstant
(String
The name of the constant.
name
)

If the named enum already exists, the reference to it is returned.

public Map<String, JEnumConstant>

Returns:

Set of enum constants keyed by names
enumConstants
()

Returns set of enum constants keyed by names.

public JFieldVar

Returns:

Newly generated field
field
(int
Modifiers for this field
mods
,
JType
JType of this field
type
,
String
Name of this field
name
)

Adds a field to the list of field members of this JDefinedClass.

public JFieldVar
field(int mods, Class<?> type, String name)

public JFieldVar

Returns:

Newly generated field
field
(int
Modifiers for this field.
mods
,
JType
JType of this field.
type
,
String
Name of this field.
name
,
JExpression
Initial value of this field.
init
)

Adds a field to the list of field members of this JDefinedClass.

public JFieldVar
field(int mods, Class<?> type, String name, JExpression init)

public Map<String, JFieldVar>

Returns:

always non-null.
fields
()

Returns all the fields declred in this class.

public String
fullName()

Implements abstract com.sun.codemodel.JType.fullName.

Gets the fully qualified name of this class.

public JTypeVar
generify(String name)

Implements com.sun.codemodel.JGenerifiable.generify.

Adds a new type variable to this declaration.

public JTypeVar
generify(String name, Class<?> bound)

Implements com.sun.codemodel.JGenerifiable.generify.

Adds a new type variable to this declaration with a bound.

public JTypeVar
generify(String name, JClass bound)

Implements com.sun.codemodel.JGenerifiable.generify.

Adds a new type variable to this declaration with a bound.

private Map<String, JDefinedClass>
public ClassType
public JMethod

Returns:

null if not found.
getConstructor
(JType[] argTypes)

Looks for a method that has the specified method signature and return it.

public JMethod

Returns:

null if not found.
getMethod
(String name, JType[] argTypes)

Looks for a method that has the specified method signature and return it.

public JPackage
getPackage()

Implements com.sun.codemodel.JClassContainer.getPackage.

Gets the nearest package parent.

public void
hide()

Mark this file as hidden, so that this file won't be generated.

public JBlock

Returns:

JBlock containing initialization statements for this class
init
()

Creates, if necessary, and returns the static initializer for this class.

public JBlock

Returns:

JBlock containing initialization statements for this class
instanceInit
()

Creates, if necessary, and returns the instance initializer for this class.

public boolean
isAbstract()

Implements abstract com.sun.codemodel.JClass.isAbstract.

Checks if this class is an abstract class.

public boolean
isAnnotationTypeDeclaration()

This method indicates if the interface is an annotationTypeDeclaration

public final boolean
isAnonymous()

Returns true if this is an anonymous class.

public boolean
isClass()

Implements com.sun.codemodel.JClassContainer.isClass.

Returns true if the container is a class.

public boolean
public boolean
isInterface()

Implements abstract com.sun.codemodel.JClass.isInterface.

Checks if this object represents an interface.

public boolean
isPackage()

Implements com.sun.codemodel.JClassContainer.isPackage.

Returns true if the container is a package.

public JDocComment

Returns:

JDocComment containing javadocs for this class
javadoc
()

Implements com.sun.codemodel.JDocCommentable.javadoc.

Creates, if necessary, and returns the class javadoc for this JDefinedClass

public final JClass[]
listClasses()

Returns all the nested classes defined in this class.

public JMethod

Returns:

Newly generated JMethod
method
(int
Modifiers for this method
mods
,
JType
Return type for this method
type
,
String
Name of the method
name
)

Add a method to the list of method members of this JDefinedClass instance.

public JMethod
method(int mods, Class<?> type, String name)

public Collection<JMethod>
methods()

Returns the set of methods defined in this class.

public JMods
mods()

Returns: the current modifiers of this class.

public String

Returns:

Name of this class
name
()

Implements abstract com.sun.codemodel.JClass.name.

JClass name accessor.

public JClass
outer()

Overrides com.sun.codemodel.JClass.outer.

Returns the class in which this class is nested, or null if this is a top-level class.

public final JClassContainer
public boolean
removeAnnotation(JAnnotationUse annotation)

Implements com.sun.codemodel.JAnnotatable.removeAnnotation.

Removes annotation from this program element.

public void
removeField(JFieldVar field)

Removes a JFieldVar from this class.

protected JClass
substituteParams(JTypeVar[] variables, List<JClass> bindings)

Implements abstract com.sun.codemodel.JClass.substituteParams.

Substitutes the type variables with their actual arguments.

public JClass
public JTypeVar[]
typeParams()

Overrides com.sun.codemodel.JClass.typeParams.

Implements com.sun.codemodel.JGenerifiable.typeParams.

Iterates all the type parameters of this class/interface.

Inherited from com.sun.codemodel.JClass:
arrayboxifydotclasserasuregenerategetBaseClassgetBaseClassgetPrimitiveTypegetTypeParametersisAssignableFromisParameterizednarrownarrownarrownarrownarrownarrowownerprintLinkstaticInvokestaticInvokestaticRefstaticReftoStringunboxifywildcard