public class GenerationHelper extends Object implements Closeable
GenerationHelper
is an internal class that provides common routines
only used by the annotation processors.Constructor and Description |
---|
GenerationHelper(Writer sourceWriter) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected String |
determineFinalConstantValue(VariableElement fieldElement)
Note that to have a constant value, a field's type must be either a primitive type or String otherwise the
value is null.
|
protected String |
determineWrapperClass(TypeMirror type)
Returns the name of the wrapper class for a primitive class.
|
String |
firstCharToUpperCase(String charSequence) |
void |
generateAnnotation(String className,
String value) |
void |
generateConstantFieldDeclaration(VariableElement fieldElement) |
void |
generateFieldDeclaration(VariableElement fieldElement) |
void |
generateFieldDeclaration(VariableElement fieldElement,
Modifier... modifiers) |
void |
generateFieldDeclarations(Collection<VariableElement> collection)
Generates all field declarations which are included in the passed list.
|
String |
generateFieldList(Collection<VariableElement> fieldElements,
boolean withType,
boolean leadingComma)
Generates a list of Fields.
|
void |
generateFooter() |
void |
generateImports(Class<?>... imports)
Use null as import to separate import groups.
|
void |
generateImports(String... imports) |
String |
generateModifierList(Modifier... modifiers) |
void |
generatePackageDeclaration(String packageName)
Generates a package declaration.
|
static String |
implode(Object[] segments,
String delimiter)
Construct a single string from an array of strings, gluing them together
with the specified delimiter.
|
boolean |
isConstant(VariableElement fieldElement)
Checks if a field contains a static or final modifier.
|
boolean |
isFinal(VariableElement fieldElement)
Checks if a field contains a final modifier.
|
boolean |
isPrimitive(TypeMirror type)
Checks if a type is a primitive type.
|
boolean |
isStatic(VariableElement fieldElement)
Checks if a field contains a static modifier.
|
protected String |
manufactureAccessorName(VariableElement fieldElement) |
String |
manufactureField(VariableElement fieldElement)
Returns the field's type together with the field's simple name.
|
protected String |
manufactureIndentation() |
protected String |
manufactureSetterName(String fieldName) |
protected String |
manufactureSetterName(VariableElement fieldElement) |
void |
print(Object o) |
void |
print(String s,
Object... parameters) |
void |
println() |
void |
println(Object o) |
void |
println(String s,
Object... parameters) |
void |
printWithoutSpaces(String s,
Object... parameters) |
static String |
replaceParameters(String target,
Object... parameters)
Replaces each placeholder of this string that matches a parameter index.
|
void |
resetWhitespaces() |
void |
setWhitespaces(int whitespace) |
public GenerationHelper(Writer sourceWriter)
public static String implode(Object[] segments, String delimiter)
segments
- array of stringsdelimiter
- character that glues the passed strings togetherpublic static String replaceParameters(String target, Object... parameters)
Placeholder format: {int}
Usage:
replaceParameters("{0} int myField = {1};", "private", 20);
target
- the string to be replace.parameters
- the replacement parametersFor example:
private int myField = 20;
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public void generateConstantFieldDeclaration(VariableElement fieldElement)
public void generateFieldDeclaration(VariableElement fieldElement)
public void generateFieldDeclaration(VariableElement fieldElement, Modifier... modifiers)
public void generateFieldDeclarations(Collection<VariableElement> collection)
public String generateFieldList(Collection<VariableElement> fieldElements, boolean withType, boolean leadingComma)
Usage:
generateFieldList(myList, true, false)
Generated example:
String myField1, int myField2, final String myField3
public void generateFooter()
public void generateImports(Class<?>... imports)
Usage:
generateImports(EventHandler
.class, GwtEvent
.class, null,
GenEventProcessor
.class)
Generated example:
import EventHandler
;
import EventHandler
;
import GenEventProcessor
;
TODO: It seems as the compiler can't find GWTP classes during generation - why?imports
- array of classes to be importedpublic void generateImports(String... imports)
generateImports(Class...)
public void generatePackageDeclaration(String packageName)
Generated example:
package com.gwtplatform.dispatch.annotation.processor;
public boolean isConstant(VariableElement fieldElement)
public boolean isFinal(VariableElement fieldElement)
public boolean isPrimitive(TypeMirror type)
public boolean isStatic(VariableElement fieldElement)
public String manufactureField(VariableElement fieldElement)
public void print(Object o)
public void println()
public void println(Object o)
public void resetWhitespaces()
public void setWhitespaces(int whitespace)
protected String determineFinalConstantValue(VariableElement fieldElement)
protected String determineWrapperClass(TypeMirror type)
protected String manufactureAccessorName(VariableElement fieldElement)
protected String manufactureSetterName(VariableElement fieldElement)
protected String manufactureIndentation()
Copyright © 2010-2014 ArcBees. All Rights Reserved.