Class CLIBeanBuilder
- All Implemented Interfaces:
CodeBuilder
CLIBeanSpec
.- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: CLIBeanBuilder.java 1061 2023-09-25 16:32:43Z tquadrat $
- Since:
- 0.1.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.config.ap.impl.codebuilders.CLIBeanBuilder"
-
Nested Class Summary
Nested classes/interfaces inherited from class org.tquadrat.foundation.config.ap.impl.codebuilders.CodeBuilderBase
CodeBuilderBase.StringConverterInstantiation
Nested classes/interfaces inherited from interface org.tquadrat.foundation.config.ap.impl.CodeBuilder
CodeBuilder.StandardField, CodeBuilder.StandardMethod
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe handler classes. -
Constructor Summary
ConstructorsConstructorDescriptionCLIBeanBuilder
(CodeGeneratorContext context) Creates a new instance ofCLIBeanBuilder
. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
build()
Generates the relevant code.private final String
composeValueHandlerCreation
(PropertySpec property) Composes the code that creates the CLI value handler for the given property.private final void
Creates the implementation for the methodCLIBeanSpec.dumpParamFileTemplate(OutputStream)
.private final void
createParseCommandLine
(FieldSpec registry, FieldSpec errorMsgHolder) Creates the implementation for the methodCLIBeanSpec.parseCommandLine(String[])
.private final void
createPrintUsage
(FieldSpec registry) Creates the implementation for the methodCLIBeanSpec.printUsage(OutputStream, CharSequence)
.private final void
createRetrieveParseErrorMessage
(FieldSpec errorMsgHolder) Creates the implementation for the methodCLIBeanSpec.retrieveParseErrorMessage()
.private final void
doBuild()
Is called bybuild()
to do the work – only if there is work to do …retrieveValueHandlerClass
(PropertySpec property) Retrieves the class for the value handler for the given property.Methods inherited from class org.tquadrat.foundation.config.ap.impl.codebuilders.CodeBuilderBase
addConstructorArgument, addConstructorCode, addConstructorSuppressedWarning, addField, addField, addMethod, addMethod, composeAddMethod, composeConstructorFragment4Environment, composeConstructorFragment4SystemPreference, composeConstructorFragment4SystemProp, composeField, composeGetter, composeSetter, determineStringConverterInstantiation, getComposer, getConfiguration, getField, getMethod, getProperties, getStringConverter, isSynchronized
-
Field Details
-
m_HandlerClasses
The handler classes.
-
-
Constructor Details
-
CLIBeanBuilder
Creates a new instance ofCLIBeanBuilder
.- Parameters:
context
- The code generator context.
-
-
Method Details
-
build
Generates the relevant code.This method checks whether there are any properties that are either options or arguments, and does the build only when there is at least one.
Not building CLI stuff will let crash the compilation of the generated code, but this is intended: either the annotation for the CLI properties is missing, or the interface
CLIBeanSpec
was added to the configuration bean specification in error.- Specified by:
build
in interfaceCodeBuilder
- Specified by:
build
in classCodeBuilderBase
-
composeValueHandlerCreation
Composes the code that creates the CLI value handler for the given property.- Parameters:
property
- The property.- Returns:
- The name of the method that creates the CLI value handler for this property.
-
createDumpParamFileTemplate
Creates the implementation for the methodCLIBeanSpec.dumpParamFileTemplate(OutputStream)
. -
createParseCommandLine
Creates the implementation for the methodCLIBeanSpec.parseCommandLine(String[])
.- Parameters:
registry
- The registry of the properties that are exposed for the CLI.errorMsgHolder
- The field for the parse errors.
-
createPrintUsage
Creates the implementation for the methodCLIBeanSpec.printUsage(OutputStream, CharSequence)
.- Parameters:
registry
- The registry of the properties that are exposed for the CLI.
-
createRetrieveParseErrorMessage
Creates the implementation for the methodCLIBeanSpec.retrieveParseErrorMessage()
.- Parameters:
errorMsgHolder
- The field for the parse errors.
-
doBuild
Is called bybuild()
to do the work – only if there is work to do … -
retrieveValueHandlerClass
Retrieves the class for the value handler for the given property. If returning
Optional.empty()
empty}, an instance ofSimpleCmdLineValueHandler
must be used that will be instantiated with theStringConverter
retrieved by a call toPropertySpec.getStringConverterClass()
.- Parameters:
property
- The property.- Returns:
- An instance of
Optional
that holds the respective type name.
-