public abstract class Generator extends Object
If annotated by @RunsLocal
, a generator can minimize its impact on compilation speed. See
Generator.RunsLocal
for details.
Resource reading should be done through the ResourceOracle in the provided GeneratorContext (not via ClassLoader.getResource(), File, or URL) so that Generator Resource dependencies can be detected and used to facilitate fast incremental recompiles.
Modifier and Type | Class and Description |
---|---|
static interface |
Generator.RunsLocal
An optional annotation indicating that a Generator can be run with local information during
incremental compilation.
|
Constructor and Description |
---|
Generator() |
Modifier and Type | Method and Description |
---|---|
static String |
escape(String unescaped)
Escapes string content to be a valid string literal.
|
static String |
escapeClassName(String unescapedString)
Returns an escaped version of a String that is valid as a Java class name.
Illegal characters become "_" + the character integer padded to 5 digits like "_01234". |
abstract String |
generate(TreeLogger logger,
GeneratorContext context,
String typeName)
Generate a default constructible subclass of the requested type.
|
public static String escape(String unescaped)
unescaped
, suitable for being enclosed in double
quotes in Java sourcepublic static String escapeClassName(String unescapedString)
public abstract String generate(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException
UnableToCompleteException
if for any reason it cannot provide a substitute classnull
to cause the requested type itself to be usedUnableToCompleteException
Copyright © 2018. All rights reserved.