Module io.helidon.builder.codegen
Package io.helidon.builder.codegen.spi
Interface BuilderCodegenExtension
public interface BuilderCodegenExtension
Extension to modify the builder and prototype that is generated.
-
Method Summary
Modifier and TypeMethodDescriptiondefault Optional<GeneratedMethod> method(OptionInfo option, GeneratedMethod method, OptionMethodType methodType) This allows modification to the methods generated for options by the default builder code generator.default List<OptionInfo> options(PrototypeInfo prototypeInfo, List<OptionInfo> existingOptions) A list of (updated) options to be used during code generation.default PrototypeInfoprototypeInfo(PrototypeInfo prototypeInfo) An extension can update the prototype information, add annotations to types, add custom methods etc.default voidupdateBuilder(PrototypeInfo prototypeInfo, List<OptionInfo> options, ClassBase.Builder<?, ?> classModel) Update the builder.default voidupdateBuilderBase(PrototypeInfo prototypeInfo, List<OptionInfo> options, ClassBase.Builder<?, ?> classModel) Update the builder base.default voidupdateImplementation(PrototypeInfo prototypeInfo, List<OptionInfo> options, ClassBase.Builder<?, ?> classModel) Update the implementation class.default voidupdatePreBuildPrototype(PrototypeInfo prototypeInfo, List<OptionInfo> options, Method.Builder method) Update thepreBuildPrototypemethod of builder base.default voidupdatePrototype(PrototypeInfo prototypeInfo, List<OptionInfo> options, ClassModel.Builder classModel) Update the prototype interface.default voidupdateValidatePrototype(PrototypeInfo prototypeInfo, List<OptionInfo> options, Method.Builder method) Update thevalidatePrototypemethod of builder base.
-
Method Details
-
prototypeInfo
An extension can update the prototype information, add annotations to types, add custom methods etc.NOTE: this method CANNOT modify options
- Parameters:
prototypeInfo- prototype information from blueprint and previous extensions- Returns:
- updated prototype information
-
options
A list of (updated) options to be used during code generation.An option is a property of the prototype, that has a prototype accessor, builder field, builder setter, and builder getter. All of these methods will be code generated. If an option is inherited from a blueprint, it is still code generated, with
Overrideannotation.- Parameters:
prototypeInfo- prototype information from blueprint and previous extensionsexistingOptions- list of options from blueprint and previous extensions- Returns:
- list of builder options
-
updatePrototype
default void updatePrototype(PrototypeInfo prototypeInfo, List<OptionInfo> options, ClassModel.Builder classModel) Update the prototype interface. This can add additional factory methods, constants, etc.Do not add properties through this method, use
options(io.helidon.builder.codegen.PrototypeInfo, java.util.List)instead.- Parameters:
prototypeInfo- prototype informationoptions- list of optionsclassModel- prototype interface class model
-
updateBuilderBase
default void updateBuilderBase(PrototypeInfo prototypeInfo, List<OptionInfo> options, ClassBase.Builder<?, ?> classModel) Update the builder base. This can add additional fields, methods, constants, etc.- Parameters:
prototypeInfo- prototype informationoptions- list of optionsclassModel- builder base class model
-
updatePreBuildPrototype
default void updatePreBuildPrototype(PrototypeInfo prototypeInfo, List<OptionInfo> options, Method.Builder method) Update thepreBuildPrototypemethod of builder base. This method is called first in the builder hierarchy to handle decorators.- Parameters:
prototypeInfo- prototype informationoptions- list of optionsmethod- method builder
-
updateValidatePrototype
default void updateValidatePrototype(PrototypeInfo prototypeInfo, List<OptionInfo> options, Method.Builder method) Update thevalidatePrototypemethod of builder base. This method is called last in the builder hierarchy to handle validation, right before calling thebuildmethod.- Parameters:
prototypeInfo- prototype informationoptions- list of optionsmethod- method builder
-
updateBuilder
default void updateBuilder(PrototypeInfo prototypeInfo, List<OptionInfo> options, ClassBase.Builder<?, ?> classModel) Update the builder.- Parameters:
prototypeInfo- prototype informationoptions- list of optionsclassModel- builder class model
-
updateImplementation
default void updateImplementation(PrototypeInfo prototypeInfo, List<OptionInfo> options, ClassBase.Builder<?, ?> classModel) Update the implementation class.Do not add properties through this method, use
options(io.helidon.builder.codegen.PrototypeInfo, java.util.List)instead.- Parameters:
prototypeInfo- prototype informationoptions- list of optionsclassModel- implementation class model
-
method
default Optional<GeneratedMethod> method(OptionInfo option, GeneratedMethod method, OptionMethodType methodType) This allows modification to the methods generated for options by the default builder code generator. To add additional methods to any of the generated code, useprototypeInfo(io.helidon.builder.codegen.PrototypeInfo).Important note: we may add new method types in minor versions of Helidon, please make sure this would not break your extension.
- Parameters:
option- option informationmethod- method to modify, possibly remove, or returnmethodType- type of the method being processed- Returns:
- updated generated method
-