public class ClassGenerationHelper extends GenerationHelper
ClassGenerationHelper
is an internal class that provides common routines
only used by the annotation processors.Constructor and Description |
---|
ClassGenerationHelper(Writer sourceWriter) |
Modifier and Type | Method and Description |
---|---|
void |
generateClassHeader(String className,
String extendedClassName,
Set<Modifier> modifiers,
String... extraInterfaces)
Generates a class header.
|
void |
generateConstructorUsingFields(String simpleClassName,
Collection<VariableElement> fieldsToBePassedAndAssigned,
Modifier... constructorModifiers) |
void |
generateEmptyConstructor(String simpleClassName,
Modifier modifier) |
void |
generateEquals(String simpleClassName,
Collection<VariableElement> fieldElements)
Creates an equals method using Java standards.
|
void |
generateFieldAccessors(Collection<VariableElement> fieldElements) |
void |
generateFieldAssignment(VariableElement fieldElement,
Object value)
Creates a default field assignment.
|
void |
generateHashCode(Collection<VariableElement> fieldElements)
Creates an hashCode method using Java standards.
|
void |
generateToString(String simpleClassName,
Collection<VariableElement> fieldElements) |
close, determineFinalConstantValue, determineWrapperClass, firstCharToUpperCase, generateAnnotation, generateConstantFieldDeclaration, generateFieldDeclaration, generateFieldDeclaration, generateFieldDeclarations, generateFieldList, generateFooter, generateImports, generateImports, generateModifierList, generatePackageDeclaration, implode, isConstant, isFinal, isPrimitive, isStatic, manufactureAccessorName, manufactureField, manufactureIndentation, manufactureSetterName, manufactureSetterName, print, print, println, println, println, printWithoutSpaces, replaceParameters, resetWhitespaces, setWhitespaces
public ClassGenerationHelper(Writer sourceWriter)
public void generateClassHeader(String className, String extendedClassName, Set<Modifier> modifiers, String... extraInterfaces)
Usage:
generateClassHeader(Foo.class.getSimpleName(),
HasName.class.getSimpleName,
"MyGenericInterface<Foo>"
)
Generated example:
public class MyFoo extends Foo implements HasName, MyGenericInterface<Foo> {
className
- the simple class namemodifiers
- the modifiers for the classextendedClassName
- the parent class nameextraInterfaces
- array of interface names to be implementedpublic void generateConstructorUsingFields(String simpleClassName, Collection<VariableElement> fieldsToBePassedAndAssigned, Modifier... constructorModifiers)
public void generateEmptyConstructor(String simpleClassName, Modifier modifier)
public void generateEquals(String simpleClassName, Collection<VariableElement> fieldElements)
simpleClassName
- the class namefieldElements
- the field elementspublic void generateFieldAccessors(Collection<VariableElement> fieldElements)
public void generateFieldAssignment(VariableElement fieldElement, Object value)
generateFieldAssignment(myNameIsTest, null)
this.test = null;
fieldElement
- value
- public void generateHashCode(Collection<VariableElement> fieldElements)
fieldElements
- the field elementspublic void generateToString(String simpleClassName, Collection<VariableElement> fieldElements)
Copyright © 2010–2014 Arcbees. All rights reserved.