public final class JAnnotationType extends JStructure
JAnnotationType type = new JAnnotationType("RequestForEnhancement"); type.addElement(new JAnnotationTypeElement("id", JType.Int)); type.addElement(new JAnnotationTypeElement("synopsis", new JType("String"))); JAnnotationTypeElement engineer; engineer = new JAnnotationTypeElement("engineer", new JType("String")); engineer.setDefaultString("\"[unassigned]\""); type.addElement(engineer); JAnnotationTypeElement date; date = new JAnnotationTypeElement("date", new JType("String")); date.setDefaultString("\"[unimplemented]\""); type.addElement(date);outputs
public @interface RequestForEnhancement { int id(); String synopsis(); String engineer() default "[unassigned]"; String date() default "[unimplemented]"; }
Constructor and Description |
---|
JAnnotationType(String name)
Creates a JAnnotationType of the given name.
|
Modifier and Type | Method and Description |
---|---|
void |
addElement(JAnnotationTypeElement jElement)
Adds the given JAnnotationTypeElement to this JAnnotationType.
|
void |
addField(JField jField)
Not implemented.
|
void |
addImport(String className)
Adds the given import to this JStructure.
|
void |
addMember(JMember jMember)
Adds the given JMember to this JAnnotationType.
|
JAnnotationTypeElement |
getElement(String name)
Returns the member with the given name, or null if no member was found
with the given name.
|
JAnnotationTypeElement[] |
getElements()
Returns an Array containing all our JAnnotationTypeElements.
|
JField |
getField(String name)
Not implemented.
|
JField[] |
getFields()
Not implemented.
|
void |
print(JSourceWriter jsw)
Deprecated.
Please use the Velocity-template based approach instead.
|
addAnnotation, addImport, addImport, addImportInternal, addInterface, getAnnotatedElementHelper, getAnnotation, getAnnotations, getFilename, getHeader, getImportCount, getImports, getInterfaceCount, getInterfaces, getJDocComment, getModifiers, getPackageName, hasAnnotations, hasImport, isAnnotationPresent, print, printHeader, printImportDeclarations, printPackageDeclaration, removeAnnotation, removeImport, removeInterface, setHeader, toString
getLocalName, getName, isArray, isPrimitive, setName
public JAnnotationType(String name)
name
- Annotation name.public void addImport(String className)
addImport
in class JStructure
className
- Name of the class to import.public void addMember(JMember jMember)
addMember
in class JStructure
jMember
- The JMember to add.public JAnnotationTypeElement[] getElements()
public JAnnotationTypeElement getElement(String name)
name
- The name of the member to return.public void addElement(JAnnotationTypeElement jElement)
jElement
- The element to add.public JField[] getFields()
getFields
in class JStructure
public JField getField(String name)
getField
in class JStructure
name
- The name of the field to return.public void addField(JField jField)
addField
in class JStructure
jField
- The JField to add.public void print(JSourceWriter jsw)
print
in class JStructure
jsw
- The JSourceWriter to print to.SourceGenerator.setJClassPrinterType(String)
Copyright © 2013. All rights reserved.