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_extendsprivate java.util.ArrayList<JType>_implementsprivate ImplJSourceFileclassFileprivate java.util.ArrayList<ClassContent>contentprivate AbstractJClassDefenclosingClassprivate JTypeerasedprivate JTypegenericprivate intmodsprivate java.lang.Stringname
-
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 anextendstype to this type.JClassDef_extends(java.lang.String name)Add anextendstype to this type.JClassDef_extends(JType type)Add anextendstype to this type.JClassDef_implements(java.lang.Class<?>... classes)Add one or moreimplementstype(s) to this type.JClassDef_implements(java.lang.String... names)Add one or moreimplementstype(s) to this type.JClassDef_implements(JType... types)Add one or moreimplementstype(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)JClassDefannotationInterface(int mods, java.lang.String name)Add a nested annotation interface to this type.JClassDefannotationInterface(java.util.ArrayList<ClassContent> content, int mods, java.lang.String name)JClassDefblankLine()Add a blank line at this point of the type.JCommentblockComment()Add a block comment.JMethodDefconstructor(int mods)Add a constructor to this type.JMethodDefconstructor(java.util.ArrayList<ClassContent> content, int mods)(package private) abstract Tokens.$KWdesignation()JTypeerasedType()Get the erased type corresponding to this type definition.JVarDeclarationfield(int mods, java.lang.Class<?> type, java.lang.String name)Add a field to this type.JVarDeclarationfield(int mods, java.lang.Class<?> type, java.lang.String name, JExpr init)Add a field to this type.JVarDeclarationfield(int mods, java.lang.String type, java.lang.String name)Add a field to this type.JVarDeclarationfield(int mods, java.lang.String type, java.lang.String name, JExpr init)Add a field to this type.JVarDeclarationfield(int mods, JType type, java.lang.String name)Add a field to this type.JVarDeclarationfield(int mods, JType type, java.lang.String name, JExpr init)Add a field to this type.JVarDeclarationfield(java.util.ArrayList<ClassContent> content, int mods, JType type, java.lang.String name, JExpr init)JTypegenericType()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) ImplJSourceFilegetClassFile()(package private) java.lang.Iterable<ClassContent>getContent()(package private) AbstractJClassDefgetEnclosingClass()(package private) JTypegetExtends()(package private) java.lang.Iterable<JType>getImplements()(package private) FormatPreferences.IndentationgetMemberIndentation()intgetModifiers()(package private) intgetMods()(package private) java.lang.StringgetName()booleanhasAllModifiers(int mods)booleanhasAnyModifier(int mods)(package private) booleanhasInterfaceStyleExtends()JBlockinit()Add a "raw" initialization block to this type definition.JBlockinit(java.util.ArrayList<ClassContent> content)JCommentlineComment()Add a line comment.JMethodDefmethod(int mods, java.lang.Class<?> returnType, java.lang.String name)Add a method to this type.JMethodDefmethod(int mods, java.lang.String returnType, java.lang.String name)Add a method to this type.JMethodDefmethod(int mods, JType returnType, java.lang.String name)Add a method to this type.JMethodDefmethod(java.util.ArrayList<ClassContent> content, int mods, JType returnType, java.lang.String name)(package private) booleanmethodCanHaveBody(int mods)JClassDefSectionsection()Create a section at this point, into which additional items may be added.JBlockstaticInit()Add a static initialization block to this type definition.JBlockstaticInit(java.util.ArrayList<ClassContent> content)(package private) booleansupportsCompactInitOnly()JTypeParamDeftypeParam(java.lang.String name)Define a type parameter.voidwrite(SourceFileWriter writer)(package private) voidwriteClassHeader(SourceFileWriter sourceFileWriter)(package private) voidwriteContent(SourceFileWriter sourceFileWriter)(package private) voidwriteContentBlock(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:JCommentableAdd a line comment.- Specified by:
lineCommentin interfaceJCommentable- Overrides:
lineCommentin classBasicJCommentable- Returns:
- the line comment body
-
blockComment
public JComment blockComment()
Description copied from interface:JCommentableAdd a block comment.- Specified by:
blockCommentin interfaceJCommentable- Overrides:
blockCommentin classBasicJCommentable- Returns:
- the block comment body
-
section
public JClassDefSection section()
Description copied from interface:JClassDefSectionCreate a section at this point, into which additional items may be added.- Specified by:
sectionin interfaceJClassDefSection- Returns:
- the new section to add
-
_extends
public JClassDef _extends(java.lang.String name)
Description copied from interface:JClassDefAdd anextendstype to this type.
-
_extends
public JClassDef _extends(JType type)
Description copied from interface:JClassDefAdd anextendstype to this type.
-
_extends
public JClassDef _extends(java.lang.Class<?> clazz)
Description copied from interface:JClassDefAdd anextendstype to this type.
-
_implements
public JClassDef _implements(java.lang.String... names)
Description copied from interface:JClassDefAdd one or moreimplementstype(s) to this type.- Specified by:
_implementsin interfaceJClassDef- Parameters:
names- the type name- Returns:
- this type definition
-
_implements
public JClassDef _implements(JType... types)
Description copied from interface:JClassDefAdd one or moreimplementstype(s) to this type.- Specified by:
_implementsin interfaceJClassDef- Parameters:
types- the type- Returns:
- this type definition
-
_implements
public JClassDef _implements(java.lang.Class<?>... classes)
Description copied from interface:JClassDefAdd one or moreimplementstype(s) to this type.- Specified by:
_implementsin interfaceJClassDef- Parameters:
classes- the type- Returns:
- this type definition
-
blankLine
public JClassDef blankLine()
Description copied from interface:JClassDefAdd a blank line at this point of the type.- Specified by:
blankLinein interfaceJClassDef- Specified by:
blankLinein interfaceJClassDefSection- Returns:
- this type definition
-
erasedType
public JType erasedType()
Description copied from interface:JClassDefGet the erased type corresponding to this type definition.- Specified by:
erasedTypein interfaceJClassDef- Returns:
- the erased type
-
genericType
public JType genericType()
Description copied from interface:JClassDefGet 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:
genericTypein interfaceJClassDef- Returns:
- the generic type
-
typeParam
public JTypeParamDef typeParam(java.lang.String name)
Description copied from interface:JGenericDefDefine a type parameter.- Specified by:
typeParamin interfaceJGenericDef- Overrides:
typeParamin classAbstractJGeneric- Parameters:
name- the type parameter name- Returns:
- the type parameter definition
-
init
public final JBlock init()
Description copied from interface:JClassDefSectionAdd a "raw" initialization block to this type definition.- Specified by:
initin interfaceJClassDefSection- Returns:
- the initialization block
-
init
public JBlock init(java.util.ArrayList<ClassContent> content)
- Specified by:
initin interfaceSectionable
-
staticInit
public final JBlock staticInit()
Description copied from interface:JClassDefSectionAdd a static initialization block to this type definition.- Specified by:
staticInitin interfaceJClassDefSection- Returns:
- the static initialization block
-
staticInit
public JBlock staticInit(java.util.ArrayList<ClassContent> content)
- Specified by:
staticInitin interfaceSectionable
-
_enum
public JEnumConstant _enum(java.lang.String name)
Description copied from interface:JClassDefAdd 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:
fieldin interfaceSectionable
-
field
public final JVarDeclaration field(int mods, JType type, java.lang.String name)
Description copied from interface:JClassDefSectionAdd a field to this type.- Specified by:
fieldin 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:JClassDefSectionAdd a field to this type.- Specified by:
fieldin 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:JClassDefSectionAdd a field to this type.- Specified by:
fieldin 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:JClassDefSectionAdd a field to this type.- Specified by:
fieldin 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:JClassDefSectionAdd a field to this type.- Specified by:
fieldin 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:JClassDefSectionAdd a field to this type.- Specified by:
fieldin 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:
methodin interfaceSectionable
-
method
public final JMethodDef method(int mods, JType returnType, java.lang.String name)
Description copied from interface:JClassDefSectionAdd a method to this type.- Specified by:
methodin 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:JClassDefSectionAdd a method to this type.- Specified by:
methodin 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:JClassDefSectionAdd a method to this type.- Specified by:
methodin 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:
constructorin interfaceSectionable
-
constructor
public final JMethodDef constructor(int mods)
Description copied from interface:JClassDefSectionAdd a constructor to this type.- Specified by:
constructorin 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:
_classin interfaceSectionable
-
_enum
public JClassDef _enum(java.util.ArrayList<ClassContent> content, int mods, java.lang.String name)
- Specified by:
_enumin interfaceSectionable
-
_interface
public JClassDef _interface(java.util.ArrayList<ClassContent> content, int mods, java.lang.String name)
- Specified by:
_interfacein interfaceSectionable
-
annotationInterface
public JClassDef annotationInterface(java.util.ArrayList<ClassContent> content, int mods, java.lang.String name)
- Specified by:
annotationInterfacein interfaceSectionable
-
_class
public final JClassDef _class(int mods, java.lang.String name)
Description copied from interface:JClassDefSectionAdd a nested class to this type.- Specified by:
_classin 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:JClassDefSectionAdd a nested enum to this type.- Specified by:
_enumin 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:JClassDefSectionAdd a nested interface to this type.- Specified by:
_interfacein 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:JClassDefSectionAdd a nested annotation interface to this type.- Specified by:
annotationInterfacein 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)
-
-