Package org.jboss.jdeparser
Class AbstractJClassDef
- java.lang.Object
-
- org.jboss.jdeparser.BasicJCommentable
-
- org.jboss.jdeparser.AbstractJDocCommentable
-
- org.jboss.jdeparser.BasicJAnnotatable
-
- org.jboss.jdeparser.AbstractJGeneric
-
- org.jboss.jdeparser.AbstractJClassDef
-
- All Implemented Interfaces:
ClassContent
,ClassFileContent
,JAnnotatable
,JClassDef
,JClassDefSection
,JCommentable
,JDocCommentable
,JGenericDef
,Sectionable
,Writable
- Direct Known Subclasses:
AnnotationJClassDef
,AnonymousJClassDef
,EnumConstantJClassDef
,EnumJClassDef
,InterfaceJClassDef
,PlainJClassDef
abstract class AbstractJClassDef extends AbstractJGeneric implements JClassDef, ClassFileContent, ClassContent, Sectionable
-
-
Field Summary
Fields Modifier and Type Field Description private JType
_extends
private java.util.ArrayList<JType>
_implements
private ImplJSourceFile
classFile
private java.util.ArrayList<ClassContent>
content
private AbstractJClassDef
enclosingClass
private JType
erased
private JType
generic
private int
mods
private java.lang.String
name
-
Constructor Summary
Constructors Constructor Description AbstractJClassDef(int mods, java.lang.String name)
AbstractJClassDef(int mods, AbstractJClassDef enclosingClass, java.lang.String name)
AbstractJClassDef(int mods, ImplJSourceFile classFile, java.lang.String name)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description JClassDef
_class(int mods, java.lang.String name)
Add a nested class to this type.JClassDef
_class(java.util.ArrayList<ClassContent> content, int mods, java.lang.String name)
JClassDef
_enum(int mods, java.lang.String name)
Add a nested enum to this type.JEnumConstant
_enum(java.lang.String name)
Add an enum constant.JClassDef
_enum(java.util.ArrayList<ClassContent> content, int mods, java.lang.String name)
JClassDef
_extends(java.lang.Class<?> clazz)
Add anextends
type to this type.JClassDef
_extends(java.lang.String name)
Add anextends
type to this type.JClassDef
_extends(JType type)
Add anextends
type to this type.JClassDef
_implements(java.lang.Class<?>... classes)
Add one or moreimplements
type(s) to this type.JClassDef
_implements(java.lang.String... names)
Add one or moreimplements
type(s) to this type.JClassDef
_implements(JType... types)
Add one or moreimplements
type(s) to this type.JClassDef
_interface(int mods, java.lang.String name)
Add a nested interface to this type.JClassDef
_interface(java.util.ArrayList<ClassContent> content, int mods, java.lang.String name)
(package private) <C extends ClassContent>
Cadd(C item)
(package private) <C extends ClassContent>
Cadd(java.util.ArrayList<ClassContent> content, C item)
JClassDef
annotationInterface(int mods, java.lang.String name)
Add a nested annotation interface to this type.JClassDef
annotationInterface(java.util.ArrayList<ClassContent> content, int mods, java.lang.String name)
JClassDef
blankLine()
Add a blank line at this point of the type.JComment
blockComment()
Add a block comment.JMethodDef
constructor(int mods)
Add a constructor to this type.JMethodDef
constructor(java.util.ArrayList<ClassContent> content, int mods)
(package private) abstract Tokens.$KW
designation()
JType
erasedType()
Get the erased type corresponding to this type definition.JVarDeclaration
field(int mods, java.lang.Class<?> type, java.lang.String name)
Add a field to this type.JVarDeclaration
field(int mods, java.lang.Class<?> type, java.lang.String name, JExpr init)
Add a field to this type.JVarDeclaration
field(int mods, java.lang.String type, java.lang.String name)
Add a field to this type.JVarDeclaration
field(int mods, java.lang.String type, java.lang.String name, JExpr init)
Add a field to this type.JVarDeclaration
field(int mods, JType type, java.lang.String name)
Add a field to this type.JVarDeclaration
field(int mods, JType type, java.lang.String name, JExpr init)
Add a field to this type.JVarDeclaration
field(java.util.ArrayList<ClassContent> content, int mods, JType type, java.lang.String name, JExpr init)
JType
genericType()
Get a generic type for this type definition, where the type arguments are the same as the type parameters of this type (as defined at the time this method is called).(package private) ImplJSourceFile
getClassFile()
(package private) java.lang.Iterable<ClassContent>
getContent()
(package private) AbstractJClassDef
getEnclosingClass()
(package private) JType
getExtends()
(package private) java.lang.Iterable<JType>
getImplements()
(package private) FormatPreferences.Indentation
getMemberIndentation()
int
getModifiers()
(package private) int
getMods()
(package private) java.lang.String
getName()
boolean
hasAllModifiers(int mods)
boolean
hasAnyModifier(int mods)
(package private) boolean
hasInterfaceStyleExtends()
JBlock
init()
Add a "raw" initialization block to this type definition.JBlock
init(java.util.ArrayList<ClassContent> content)
JComment
lineComment()
Add a line comment.JMethodDef
method(int mods, java.lang.Class<?> returnType, java.lang.String name)
Add a method to this type.JMethodDef
method(int mods, java.lang.String returnType, java.lang.String name)
Add a method to this type.JMethodDef
method(int mods, JType returnType, java.lang.String name)
Add a method to this type.JMethodDef
method(java.util.ArrayList<ClassContent> content, int mods, JType returnType, java.lang.String name)
(package private) boolean
methodCanHaveBody(int mods)
JClassDefSection
section()
Create a section at this point, into which additional items may be added.JBlock
staticInit()
Add a static initialization block to this type definition.JBlock
staticInit(java.util.ArrayList<ClassContent> content)
(package private) boolean
supportsCompactInitOnly()
JTypeParamDef
typeParam(java.lang.String name)
Define a type parameter.void
write(SourceFileWriter writer)
(package private) void
writeClassHeader(SourceFileWriter sourceFileWriter)
(package private) void
writeContent(SourceFileWriter sourceFileWriter)
(package private) void
writeContentBlock(SourceFileWriter sourceFileWriter)
-
Methods inherited from class org.jboss.jdeparser.AbstractJGeneric
typeParams, typeParamsToArgs, writeTypeParams
-
Methods inherited from class org.jboss.jdeparser.BasicJAnnotatable
annotate, annotate, annotate, writeAnnotations
-
Methods inherited from class org.jboss.jdeparser.AbstractJDocCommentable
deprecated, docComment, writeDocComments
-
Methods inherited from class org.jboss.jdeparser.BasicJCommentable
writeComments
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.jdeparser.JAnnotatable
annotate, annotate, annotate
-
Methods inherited from interface org.jboss.jdeparser.JDocCommentable
deprecated, docComment
-
Methods inherited from interface org.jboss.jdeparser.JGenericDef
typeParams
-
-
-
-
Field Detail
-
mods
private final int mods
-
name
private final java.lang.String name
-
enclosingClass
private final AbstractJClassDef enclosingClass
-
classFile
private final ImplJSourceFile classFile
-
content
private final java.util.ArrayList<ClassContent> content
-
_extends
private JType _extends
-
_implements
private java.util.ArrayList<JType> _implements
-
erased
private JType erased
-
generic
private JType generic
-
-
Constructor Detail
-
AbstractJClassDef
AbstractJClassDef(int mods, java.lang.String name)
-
AbstractJClassDef
AbstractJClassDef(int mods, AbstractJClassDef enclosingClass, java.lang.String name)
-
AbstractJClassDef
AbstractJClassDef(int mods, ImplJSourceFile classFile, java.lang.String name)
-
-
Method Detail
-
getEnclosingClass
AbstractJClassDef getEnclosingClass()
-
getClassFile
ImplJSourceFile getClassFile()
-
getMods
int getMods()
-
getName
java.lang.String getName()
-
add
<C extends ClassContent> C add(C item)
-
add
<C extends ClassContent> C add(java.util.ArrayList<ClassContent> content, C item)
-
lineComment
public JComment lineComment()
Description copied from interface:JCommentable
Add a line comment.- Specified by:
lineComment
in interfaceJCommentable
- Overrides:
lineComment
in classBasicJCommentable
- Returns:
- the line comment body
-
blockComment
public JComment blockComment()
Description copied from interface:JCommentable
Add a block comment.- Specified by:
blockComment
in interfaceJCommentable
- Overrides:
blockComment
in classBasicJCommentable
- Returns:
- the block comment body
-
section
public JClassDefSection section()
Description copied from interface:JClassDefSection
Create a section at this point, into which additional items may be added.- Specified by:
section
in interfaceJClassDefSection
- Returns:
- the new section to add
-
_extends
public JClassDef _extends(java.lang.String name)
Description copied from interface:JClassDef
Add anextends
type to this type.
-
_extends
public JClassDef _extends(JType type)
Description copied from interface:JClassDef
Add anextends
type to this type.
-
_extends
public JClassDef _extends(java.lang.Class<?> clazz)
Description copied from interface:JClassDef
Add anextends
type to this type.
-
_implements
public JClassDef _implements(java.lang.String... names)
Description copied from interface:JClassDef
Add one or moreimplements
type(s) to this type.- Specified by:
_implements
in interfaceJClassDef
- Parameters:
names
- the type name- Returns:
- this type definition
-
_implements
public JClassDef _implements(JType... types)
Description copied from interface:JClassDef
Add one or moreimplements
type(s) to this type.- Specified by:
_implements
in interfaceJClassDef
- Parameters:
types
- the type- Returns:
- this type definition
-
_implements
public JClassDef _implements(java.lang.Class<?>... classes)
Description copied from interface:JClassDef
Add one or moreimplements
type(s) to this type.- Specified by:
_implements
in interfaceJClassDef
- Parameters:
classes
- the type- Returns:
- this type definition
-
blankLine
public JClassDef blankLine()
Description copied from interface:JClassDef
Add a blank line at this point of the type.- Specified by:
blankLine
in interfaceJClassDef
- Specified by:
blankLine
in interfaceJClassDefSection
- Returns:
- this type definition
-
erasedType
public JType erasedType()
Description copied from interface:JClassDef
Get the erased type corresponding to this type definition.- Specified by:
erasedType
in interfaceJClassDef
- Returns:
- the erased type
-
genericType
public JType genericType()
Description copied from interface:JClassDef
Get a generic type for this type definition, where the type arguments are the same as the type parameters of this type (as defined at the time this method is called).- Specified by:
genericType
in interfaceJClassDef
- Returns:
- the generic type
-
typeParam
public JTypeParamDef typeParam(java.lang.String name)
Description copied from interface:JGenericDef
Define a type parameter.- Specified by:
typeParam
in interfaceJGenericDef
- Overrides:
typeParam
in classAbstractJGeneric
- Parameters:
name
- the type parameter name- Returns:
- the type parameter definition
-
init
public final JBlock init()
Description copied from interface:JClassDefSection
Add a "raw" initialization block to this type definition.- Specified by:
init
in interfaceJClassDefSection
- Returns:
- the initialization block
-
init
public JBlock init(java.util.ArrayList<ClassContent> content)
- Specified by:
init
in interfaceSectionable
-
staticInit
public final JBlock staticInit()
Description copied from interface:JClassDefSection
Add a static initialization block to this type definition.- Specified by:
staticInit
in interfaceJClassDefSection
- Returns:
- the static initialization block
-
staticInit
public JBlock staticInit(java.util.ArrayList<ClassContent> content)
- Specified by:
staticInit
in interfaceSectionable
-
_enum
public JEnumConstant _enum(java.lang.String name)
Description copied from interface:JClassDef
Add an enum constant. If the class being defined is not an enum, an exception is thrown.
-
field
public JVarDeclaration field(java.util.ArrayList<ClassContent> content, int mods, JType type, java.lang.String name, JExpr init)
- Specified by:
field
in interfaceSectionable
-
field
public final JVarDeclaration field(int mods, JType type, java.lang.String name)
Description copied from interface:JClassDefSection
Add a field to this type.- Specified by:
field
in interfaceJClassDefSection
- Parameters:
mods
- the modifierstype
- the field typename
- the field name- Returns:
- the field declaration
-
field
public final JVarDeclaration field(int mods, JType type, java.lang.String name, JExpr init)
Description copied from interface:JClassDefSection
Add a field to this type.- Specified by:
field
in interfaceJClassDefSection
- Parameters:
mods
- the modifierstype
- the field typename
- the field nameinit
- the field assigned value- Returns:
- the field declaration
-
field
public final JVarDeclaration field(int mods, java.lang.Class<?> type, java.lang.String name)
Description copied from interface:JClassDefSection
Add a field to this type.- Specified by:
field
in interfaceJClassDefSection
- Parameters:
mods
- the modifierstype
- the field typename
- the field name- Returns:
- the field declaration
-
field
public final JVarDeclaration field(int mods, java.lang.Class<?> type, java.lang.String name, JExpr init)
Description copied from interface:JClassDefSection
Add a field to this type.- Specified by:
field
in interfaceJClassDefSection
- Parameters:
mods
- the modifierstype
- the field typename
- the field nameinit
- the field assigned value- Returns:
- the field declaration
-
field
public final JVarDeclaration field(int mods, java.lang.String type, java.lang.String name)
Description copied from interface:JClassDefSection
Add a field to this type.- Specified by:
field
in interfaceJClassDefSection
- Parameters:
mods
- the modifierstype
- the field typename
- the field name- Returns:
- the field declaration
-
field
public final JVarDeclaration field(int mods, java.lang.String type, java.lang.String name, JExpr init)
Description copied from interface:JClassDefSection
Add a field to this type.- Specified by:
field
in interfaceJClassDefSection
- Parameters:
mods
- the modifierstype
- the field typename
- the field nameinit
- the field assigned value- Returns:
- the field declaration
-
method
public JMethodDef method(java.util.ArrayList<ClassContent> content, int mods, JType returnType, java.lang.String name)
- Specified by:
method
in interfaceSectionable
-
method
public final JMethodDef method(int mods, JType returnType, java.lang.String name)
Description copied from interface:JClassDefSection
Add a method to this type.- Specified by:
method
in interfaceJClassDefSection
- Parameters:
mods
- the modifiersreturnType
- the method return typename
- the method name- Returns:
- the method definition
-
method
public final JMethodDef method(int mods, java.lang.Class<?> returnType, java.lang.String name)
Description copied from interface:JClassDefSection
Add a method to this type.- Specified by:
method
in interfaceJClassDefSection
- Parameters:
mods
- the modifiersreturnType
- the method return typename
- the method name- Returns:
- the method definition
-
method
public final JMethodDef method(int mods, java.lang.String returnType, java.lang.String name)
Description copied from interface:JClassDefSection
Add a method to this type.- Specified by:
method
in interfaceJClassDefSection
- Parameters:
mods
- the modifiersreturnType
- the method return typename
- the method name- Returns:
- the method definition
-
methodCanHaveBody
boolean methodCanHaveBody(int mods)
-
hasInterfaceStyleExtends
boolean hasInterfaceStyleExtends()
-
supportsCompactInitOnly
boolean supportsCompactInitOnly()
-
constructor
public JMethodDef constructor(java.util.ArrayList<ClassContent> content, int mods)
- Specified by:
constructor
in interfaceSectionable
-
constructor
public final JMethodDef constructor(int mods)
Description copied from interface:JClassDefSection
Add a constructor to this type.- Specified by:
constructor
in interfaceJClassDefSection
- Parameters:
mods
- the modifiers- Returns:
- the constructor definition
-
_class
public JClassDef _class(java.util.ArrayList<ClassContent> content, int mods, java.lang.String name)
- Specified by:
_class
in interfaceSectionable
-
_enum
public JClassDef _enum(java.util.ArrayList<ClassContent> content, int mods, java.lang.String name)
- Specified by:
_enum
in interfaceSectionable
-
_interface
public JClassDef _interface(java.util.ArrayList<ClassContent> content, int mods, java.lang.String name)
- Specified by:
_interface
in interfaceSectionable
-
annotationInterface
public JClassDef annotationInterface(java.util.ArrayList<ClassContent> content, int mods, java.lang.String name)
- Specified by:
annotationInterface
in interfaceSectionable
-
_class
public final JClassDef _class(int mods, java.lang.String name)
Description copied from interface:JClassDefSection
Add a nested class to this type.- Specified by:
_class
in interfaceJClassDefSection
- Parameters:
mods
- the class modifiersname
- the class name- Returns:
- the nested class
-
_enum
public final JClassDef _enum(int mods, java.lang.String name)
Description copied from interface:JClassDefSection
Add a nested enum to this type.- Specified by:
_enum
in interfaceJClassDefSection
- Parameters:
mods
- the enum modifiersname
- the enum name- Returns:
- the nested enum
-
_interface
public final JClassDef _interface(int mods, java.lang.String name)
Description copied from interface:JClassDefSection
Add a nested interface to this type.- Specified by:
_interface
in interfaceJClassDefSection
- Parameters:
mods
- the interface modifiersname
- the interface name- Returns:
- the nested interface
-
annotationInterface
public final JClassDef annotationInterface(int mods, java.lang.String name)
Description copied from interface:JClassDefSection
Add a nested annotation interface to this type.- Specified by:
annotationInterface
in interfaceJClassDefSection
- Parameters:
mods
- the annotation interface modifiersname
- the annotation interface name- Returns:
- the nested annotation interface
-
getContent
java.lang.Iterable<ClassContent> getContent()
-
getExtends
JType getExtends()
-
getImplements
java.lang.Iterable<JType> getImplements()
-
designation
abstract Tokens.$KW designation()
-
getMemberIndentation
FormatPreferences.Indentation getMemberIndentation()
-
write
public void write(SourceFileWriter writer) throws java.io.IOException
-
writeContentBlock
void writeContentBlock(SourceFileWriter sourceFileWriter) throws java.io.IOException
- Throws:
java.io.IOException
-
writeClassHeader
void writeClassHeader(SourceFileWriter sourceFileWriter) throws java.io.IOException
- Throws:
java.io.IOException
-
writeContent
void writeContent(SourceFileWriter sourceFileWriter) throws java.io.IOException
- Throws:
java.io.IOException
-
getModifiers
public int getModifiers()
-
hasAllModifiers
public boolean hasAllModifiers(int mods)
-
hasAnyModifier
public boolean hasAnyModifier(int mods)
-
-