Class CodeGenerator<T>
- Type Parameters:
T
- The interface that results from compiling and merging the runtime code that is generated.
Drill supports two ways to generate and compile the code from a code generator: via byte-code manipulations or as "plain Java."
When using byte-code transformations, the code generator is used with a class transformer to merge precompiled template code with runtime generated and compiled query specific code to create a runtime instance.
The code generator can optionally be marked as "plain Java" capable.
This means that the generated code can be compiled directly as a Java
class without the normal byte-code manipulations. Plain Java allows
the option to persist, and debug, the generated code when building new
generated classes or otherwise working with generated code. To turn
on debugging, see the explanation in ClassBuilder
.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
void
generate()
static <T> CodeGenerator<T>
get
(MappingSet mappingSet, TemplateClassDefinition<T> definition, OptionSet optionManager) static <T> CodeGenerator<T>
get
(TemplateClassDefinition<T> definition) static <T> CodeGenerator<T>
get
(TemplateClassDefinition<T> definition, OptionSet optionManager) getRoot()
static <T> ClassGenerator<T>
getRoot
(MappingSet mappingSet, TemplateClassDefinition<T> definition, OptionSet optionManager) static <T> ClassGenerator<T>
getRoot
(TemplateClassDefinition<T> definition, OptionSet optionManager) int
hashCode()
boolean
boolean
void
plainJavaCapable
(boolean flag) Indicates that the code for this class can be generated using the "Plain Java" mechanism based on inheritance.void
preferPlainJava
(boolean flag) Identifies that this generated class should be generated via the plain Java mechanism.void
saveCodeForDebugging
(boolean persist) Debug-time option to persist the code for the generated class to permit debugging.boolean
-
Method Details
-
plainJavaCapable
public void plainJavaCapable(boolean flag) Indicates that the code for this class can be generated using the "Plain Java" mechanism based on inheritance. The byte-code method is more lenient, so some code is missing some features such as proper exception labeling, etc. Set this option to true once the generation mechanism for a class has been cleaned up to work via the plain Java mechanism.- Parameters:
flag
- true if the code generated from this instance is ready to be compiled as a plain Java class
-
preferPlainJava
public void preferPlainJava(boolean flag) Identifies that this generated class should be generated via the plain Java mechanism. This flag only has meaning if the generated class is capable of plain Java generation.- Parameters:
flag
- true if the class should be generated and compiled as a plain Java class (rather than via byte-code manipulations)
-
supportsPlainJava
public boolean supportsPlainJava() -
isPlainJava
public boolean isPlainJava() -
saveCodeForDebugging
public void saveCodeForDebugging(boolean persist) Debug-time option to persist the code for the generated class to permit debugging. Has effect only when code is generated using the plain Java option. Code is written to the code directory specified inClassBuilder
. To debug code, set this option, then point your IDE to the code directory when the IDE prompts you for the source code location.- Parameters:
persist
- true to write the code to disk, false (the default) to keep code only in memory.
-
isCodeToBeSaved
public boolean isCodeToBeSaved() -
getRoot
-
generate
public void generate() -
generateAndGet
- Throws:
IOException
-
getGeneratedCode
-
getDefinition
-
getMaterializedClassName
-
getClassName
-
get
-
get
public static <T> CodeGenerator<T> get(TemplateClassDefinition<T> definition, OptionSet optionManager) -
getRoot
public static <T> ClassGenerator<T> getRoot(TemplateClassDefinition<T> definition, OptionSet optionManager) -
getRoot
public static <T> ClassGenerator<T> getRoot(MappingSet mappingSet, TemplateClassDefinition<T> definition, OptionSet optionManager) -
get
public static <T> CodeGenerator<T> get(MappingSet mappingSet, TemplateClassDefinition<T> definition, OptionSet optionManager) -
hashCode
public int hashCode() -
equals
-