This repository was archived by the owner on May 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Plugin Development
Shaun Francis edited this page Sep 7, 2017
·
7 revisions
All Class Generator Plugins implement the ClassGeneratorPlugin interface:
public interface ClassGeneratorPlugin {
TypeSpec.Builder generateWith(final TypeSpec.Builder typeSpecBuilder,
final ClassDefinition classDefinition,
final JavaGeneratorFactory javaGeneratorFactory,
final ClassNameFactory classNameFactory,
final GenerationContext generationContext);
}
- TypeSpec.Builder - The Java Poet TypeSpec Builder use this to add new fields and methods that generate the Java Class. Should be the returned TypeSpec.Builder.
- ClassDefinition - This has definition information about the Class being generated, the type class, and child definitions
- JavaGeneratorFactory - Factory for converting child definitions into generators
- ClassNameFactory - Returns the Java Poet TypeName for a child definition, this will also apply any TypeNamePlugins before returning the TypeName
- GenerationContext - Can supply the source filename, package name, and output directory path.
All Type Name Plugins implement the TypeNamePlugin interface:
public interface TypeNamePlugin {
TypeName modifyTypeName(final TypeName typeName, final Definition definition);
}
- TypeName - Java Poet TypeName this can be wrapped then returned, for example when creating Optionals, or a completely different TypeName can be returned.
- Definition - The definition that requires a new TypeName, this can be interrogated for type.