Class CodeGenerationConfiguration
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: CodeGenerationConfiguration.java 1105 2024-02-28 12:58:46Z tquadrat $
- Since:
- 0.1.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.config.ap.CodeGenerationConfiguration"
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
The base bundle name for the resource bundle if i18n support is required.private final TypeName
The optional base class for the new configuration bean.private final Instant
The build time; this is provided by the configuration as this allows easier testing.private final Name
The class name for the configuration bean class, without the package.private final JavaComposer
TheJavaComposer
instance that is used for the code generation.private final APHelper
The processing environment.private String
The comment for the configuration file.private boolean
The flag that indicates whether the configuration must exist prior to the first open attempt.private String
The name for the configuration file.TheINI
file groups.private MethodSpec
The method that is provided as a source for the initialisation of the properties of the configuration bean.private String
The name of the resource that is used to initialise the properties of the configuration bean.private final Collection
<TypeName> The interfaces that are extended by the configuration bean specification.private String
The message prefix for the i18n support.private final Name
The name of the package for the configuration bean.private TypeName
The change listener class for thePreferences
.private String
The name of the preferences root node.private final SortedMap
<String, PropertySpecImpl> The properties for the configuration bean.private final ClassName
The configuration bean specification.private final boolean
This flag indicates whether the access to the configuration bean properties must be thread-safe. -
Constructor Summary
ConstructorsConstructorDescriptionCodeGenerationConfiguration
(APHelper environment, JavaComposer composer, ClassName specification, Name className, Name packageName, TypeName baseClass, boolean synchronizeAccess) Creates an instance ofCodeGenerationConfiguration
. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addINIGroup
(String name, String comment) Adds anINI
file group.final void
addINIGroup
(INIGroup group) Adds anINI
file group.final void
addInterfacesToImplement
(Collection<? extends TypeName> interfacesToImplement) Adds some interfaces that have to be implemented by the new configuration beam.final void
addProperty
(PropertySpec property) Adds a property to the new configuration bean.Returns the name of the field that holds the base bundle name for the resource bundle, in case i18n support is configured.Returns the base class for the new configuration bean.final Instant
Returns the build time for the new configuration bean.final Name
Returns the name of the class for the new configuration bean.final JavaComposer
Returns theJavaComposer
instance that is used for the code generation.final Elements
Returns an implementation of some utility methods for operating on elements.final APHelper
Returns the processing environment.Returns the comment for theINI
file.final boolean
Returns the flag that indicates whether the configuration file must exist before the program starts.Returns the name for the file that backs theINIFile
instance used by the generated configuration bean.Returns theINI
file groups.final Optional
<MethodSpec> Returns the method that is provided as a source for the initialisation of the properties of the configuration bean.Returns the name of the resource that is used to initialise the properties of the configuration bean.final Collection
<TypeName> Returns the interfaces that have to be implemented by the new configuration bean.Returns the name of the field that holds the message prefix, in case i18n support is configured.final Name
Returns the name of the package for the new configuration bean.Returns the class for thePreferences
change listener.final String
Returns the name for thePreferences
root node.final Optional
<PropertySpec> getProperty
(String propertyName) Returns the property with the given name.final ClassName
Returns the configuration bean specification.final boolean
Returns the flag that controls whether the generated code for the access to the configuration bean properties has to be thread-safe.final boolean
hasProperty
(String propertyName) Checks whether a property with the given name does already exist.final boolean
implementInterface
(Type interfaceToImplement) Checks whether the given interface must be implemented by the new configuration bean.final boolean
implementInterface
(TypeName interfaceToImplement) Checks whether the given interface must be implemented by the new configuration bean.final Iterator
<PropertySpec> Returns anIterator
over the defined properties.final void
setI18NParameters
(String messagePrefix, String baseBundleName) Sets the i18n parameters.final void
setINIFileConfig
(String filename, boolean flag, String comment) Sets the configuration for theINI
file.final void
setInitDataMethod
(MethodSpec method) Set the method that is provided as a source for the initialisation of the properties of the configuration bean.final void
setInitDataResource
(String initDataResource) Set the name of the resource that is used to initialise the properties of the configuration bean.final void
setPreferenceChangeListenerClass
(TypeName listenerClass) Sets the class for thePreferences
change listener.final void
setPreferencesRoot
(String name) Sets the name for the preferences root node.
-
Field Details
-
m_BaseBundleName
The base bundle name for the resource bundle if i18n support is required.- Note:
-
- This is not the value but the fully qualified field name where to find that value!
-
m_BaseClass
The optional base class for the new configuration bean. -
m_BuildTime
The build time; this is provided by the configuration as this allows easier testing. -
m_ClassName
The class name for the configuration bean class, without the package. -
m_Composer
TheJavaComposer
instance that is used for the code generation. -
m_Environment
The processing environment. -
m_INIFileComment
The comment for the configuration file. -
m_INIFileMustExist
The flag that indicates whether the configuration must exist prior to the first open attempt. -
m_INIFilePath
The name for the configuration file. -
m_INIGroups
TheINI
file groups. The key is the name of the group, the value is the respective comment for the group. -
m_InitDataMethod
The method that is provided as a source for the initialisation of the properties of the configuration bean. -
m_InitDataResource
The name of the resource that is used to initialise the properties of the configuration bean. -
m_InterfacesToImplement
The interfaces that are extended by the configuration bean specification. -
m_MessagePrefix
The message prefix for the i18n support.- Note:
-
- This is not the value but the fully qualified field name where to find that value!
-
m_PackageName
The name of the package for the configuration bean. -
m_PreferenceChangeListenerClass
The change listener class for thePreferences
. -
m_Properties
The properties for the configuration bean. The name of the property is the key.
-
m_Specification
The configuration bean specification. -
m_PreferencesRoot
The name of the preferences root node. -
m_SynchronizeAccess
This flag indicates whether the access to the configuration bean properties must be thread-safe.
-
-
Constructor Details
-
CodeGenerationConfiguration
public CodeGenerationConfiguration(APHelper environment, JavaComposer composer, ClassName specification, Name className, Name packageName, TypeName baseClass, boolean synchronizeAccess) Creates an instance ofCodeGenerationConfiguration
.- Parameters:
environment
- The access to the processing environment.composer
- TheJavaComposer
instance that is used for the code generation.specification
- The configuration specification, the interface that defines the configuration bean.className
- The name for the configuration bean class, without the package name.packageName
- The name of the package for the configuration bean class.baseClass
- The optional base class for the new configuration bean class.synchronizeAccess
-true
if the access to the configuration bean properties should be thread safe,false
if a synchronisation/locking is not required.
-
-
Method Details
-
addINIGroup
Adds anINI
file group.- Parameters:
name
- The name for the group.comment
- The comment for the group.
-
addINIGroup
Adds anINI
file group.- Parameters:
group
- The group definition.
-
addInterfacesToImplement
Adds some interfaces that have to be implemented by the new configuration beam.- Parameters:
interfacesToImplement
- The classes for the interfaces to implement.
-
addProperty
Adds a property to the new configuration bean.
If a property with the same name as the new one already exists, a
CodeGenerationError
will be thrown.- Parameters:
property
- The property- Throws:
CodeGenerationError
- There is a duplicate property.
-
getBaseBundleName
Returns the name of the field that holds the base bundle name for the resource bundle, in case i18n support is configured.- Returns:
- An instance of
Optional
holding the fully qualified field name.
-
getBaseClass
Returns the base class for the new configuration bean.- Returns:
- An instance of
Optional
that holds the base class.
-
getBuildTime
Returns the build time for the new configuration bean.- Returns:
- The build time.
-
getClassName
Returns the name of the class for the new configuration bean.- Returns:
- The class name.
-
getComposer
Returns theJavaComposer
instance that is used for the code generation.- Returns:
- The composer instance.
-
getElementUtils
Returns an implementation of some utility methods for operating on elements.- Returns:
- The element utilities.
-
getEnvironment
Returns the processing environment.- Returns:
- The processing environment.
-
getINIFileComment
Returns the comment for theINI
file.- Returns:
- The comment for the configuration file.
-
getINIFileMustExist
Returns the flag that indicates whether the configuration file must exist before the program starts.- Returns:
true
if the file must exist already,false
if it will be created on startup.- See Also:
-
getINIFilePath
Returns the name for the file that backs theINIFile
instance used by the generated configuration bean.- Returns:
- An instance of
Optional
that holds the filename.
-
getINIGroups
Returns theINI
file groups.- Returns:
- The group names and the related comments.
-
getInitDataMethod
Returns the method that is provided as a source for the initialisation of the properties of the configuration bean.
It it is
default
orstatic
, the implementation of the method has to be part of the configuration bean specification interface itself, otherwise it has to be implemented in base class.It is an error if there is an
initData()
method that is neitherdefault
norstatic
, and no base class is defined with the@ConfigurationBeanSpecificatgion
annotation.The signature for the method has to be
public Map<String,Object> initData() throws Exception
and the return value is a map with the initialisation values, where the property names are the keys.
- Returns:
- An instance of
Optional
that holds the method. - See Also:
-
getInitDataResource
Returns the name of the resource that is used to initialise the properties of the configuration bean.- Returns:
- An instance of
Optional
that holds the resource name.
-
getInterfacesToImplement
Returns the interfaces that have to be implemented by the new configuration bean.- Returns:
- The interfaces to implement.
-
getMessagePrefix
Returns the name of the field that holds the message prefix, in case i18n support is configured.- Returns:
- An instance of
Optional
holding the fully qualified field name.
-
getPackageName
Returns the name of the package for the new configuration bean.- Returns:
- The package name.
-
getPreferenceChangeListenerClass
Returns the class for the
Preferences
change listener. If no listener class is defined, the change listener support for thePreferences
will be omitted.- Returns:
- An instance of
Optional
that holds the listener class. - See Also:
-
getPreferencesRoot
Returns the name for thePreferences
root node.- Returns:
- The name for the
Preferences
root node. - See Also:
-
getProperty
Returns the property with the given name.- Parameters:
propertyName
- The name of the property.- Returns:
- An instance of
Optional
that holds the retrieved property.
-
getSpecification
Returns the configuration bean specification.- Returns:
- The configuration bean specification.
-
getSynchronizationRequired
Returns the flag that controls whether the generated code for the access to the configuration bean properties has to be thread-safe.- Returns:
true
if synchronisation/locking is required,false
if not.
-
hasProperty
Checks whether a property with the given name does already exist.- Parameters:
propertyName
- The name of the property.- Returns:
true
if the property with the given name already exists,false
otherwise.
-
implementInterface
Checks whether the given interface must be implemented by the new configuration bean.- Parameters:
interfaceToImplement
- The class for the interface that has to be implemented.- Returns:
true
if the given interface must be implemented,false
otherwise.
-
implementInterface
Checks whether the given interface must be implemented by the new configuration bean.- Parameters:
interfaceToImplement
- The class for the interface that has to be implemented.- Returns:
true
if the given interface must be implemented,false
otherwise.
-
propertyIterator
Returns anIterator
over the defined properties.- Returns:
- The iterator.
-
setI18NParameters
Sets the i18n parameters.- Parameters:
messagePrefix
- The value for the message prefix.baseBundleName
- The name of the base bundle.
-
setINIFileConfig
Sets the configuration for theINI
file.- Parameters:
filename
- The path; can benull
.flag
- The flag that indicates whether the configuration file must exist before the program starts.true
if the file must exist,false
if it will be created on startup.comment
- The comment; can benull
.
-
setInitDataMethod
Set the method that is provided as a source for the initialisation of the properties of the configuration bean.- Parameters:
method
- The method; can benull
.
-
setInitDataResource
Set the name of the resource that is used to initialise the properties of the configuration bean.- Parameters:
initDataResource
- The resource name; can benull
.
-
setPreferenceChangeListenerClass
Sets the class for thePreferences
change listener.- Parameters:
listenerClass
- The listener class; can benull
.- See Also:
-
setPreferencesRoot
Sets the name for the preferences root node.- Parameters:
name
- The name for the preferences root node.
-