Class CodeGenerationConfiguration

java.lang.Object
org.tquadrat.foundation.config.ap.CodeGenerationConfiguration

@ClassVersion(sourceVersion="$Id: CodeGenerationConfiguration.java 1105 2024-02-28 12:58:46Z tquadrat $") @API(status=MAINTAINED, since="0.1.0") public final class CodeGenerationConfiguration extends Object
An instance of this class provides the configuration for the code generation, and it collects the results from the different code generators.
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"

UML Diagram for "org.tquadrat.foundation.config.ap.CodeGenerationConfiguration"

UML Diagram for "org.tquadrat.foundation.config.ap.CodeGenerationConfiguration"
  • 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

      private final TypeName m_BaseClass
      The optional base class for the new configuration bean.
    • m_BuildTime

      private final Instant m_BuildTime
      The build time; this is provided by the configuration as this allows easier testing.
    • m_ClassName

      private final Name m_ClassName
      The class name for the configuration bean class, without the package.
    • m_Composer

      private final JavaComposer m_Composer
      The JavaComposer instance that is used for the code generation.
    • m_Environment

      private final APHelper m_Environment
      The processing environment.
    • m_INIFileComment

      The comment for the configuration file.
    • m_INIFileMustExist

      private boolean 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

      private final Map<String,String> m_INIGroups
      The INI 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

      private final Name m_PackageName
      The name of the package for the configuration bean.
    • m_PreferenceChangeListenerClass

      The change listener class for the Preferences.
    • m_Properties

      The properties for the configuration bean. The name of the property is the key.

    • m_Specification

      private final ClassName m_Specification
      The configuration bean specification.
    • m_PreferencesRoot

      The name of the preferences root node.
    • m_SynchronizeAccess

      private final boolean 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 of CodeGenerationConfiguration.
      Parameters:
      environment - The access to the processing environment.
      composer - The JavaComposer 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

      public final void addINIGroup(String name, String comment)
      Adds an INI file group.
      Parameters:
      name - The name for the group.
      comment - The comment for the group.
    • addINIGroup

      public final void addINIGroup(INIGroup group)
      Adds an INI file group.
      Parameters:
      group - The group definition.
    • addInterfacesToImplement

      public final void addInterfacesToImplement(Collection<? extends TypeName> interfacesToImplement)
      Adds some interfaces that have to be implemented by the new configuration beam.
      Parameters:
      interfacesToImplement - The classes for the interfaces to implement.
    • addProperty

      public final void addProperty(PropertySpec property) throws CodeGenerationError

      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

      public final Optional<TypeName> getBaseClass()
      Returns the base class for the new configuration bean.
      Returns:
      An instance of Optional that holds the base class.
    • getBuildTime

      public final Instant getBuildTime()
      Returns the build time for the new configuration bean.
      Returns:
      The build time.
    • getClassName

      public final Name getClassName()
      Returns the name of the class for the new configuration bean.
      Returns:
      The class name.
    • getComposer

      public final JavaComposer getComposer()
      Returns the JavaComposer instance that is used for the code generation.
      Returns:
      The composer instance.
    • getElementUtils

      public final Elements getElementUtils()
      Returns an implementation of some utility methods for operating on elements.
      Returns:
      The element utilities.
    • getEnvironment

      public final APHelper getEnvironment()
      Returns the processing environment.
      Returns:
      The processing environment.
    • getINIFileComment

      Returns the comment for the INI file.
      Returns:
      The comment for the configuration file.
    • getINIFileMustExist

      public final boolean 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

      public final Optional<String> getINIFilePath()
      Returns the name for the file that backs the INIFile instance used by the generated configuration bean.
      Returns:
      An instance of Optional that holds the filename.
    • getINIGroups

      public final Map<String,String> getINIGroups()
      Returns the INI 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 or static, 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 neither default nor static, 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

      public final Optional<String> 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

      public final 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 the Preferences will be omitted.

      Returns:
      An instance of Optional that holds the listener class.
      See Also:
    • getPreferencesRoot

      public final String getPreferencesRoot()
      Returns the name for the Preferences root node.
      Returns:
      The name for the Preferences root node.
      See Also:
    • getProperty

      public final Optional<PropertySpec> getProperty(String propertyName)
      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

      public final ClassName getSpecification()
      Returns the configuration bean specification.
      Returns:
      The configuration bean specification.
    • getSynchronizationRequired

      public final boolean 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

      public final boolean hasProperty(String propertyName)
      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

      public final boolean implementInterface(TypeName interfaceToImplement)
      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

      public final boolean implementInterface(Type interfaceToImplement)
      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 an Iterator over the defined properties.
      Returns:
      The iterator.
    • setI18NParameters

      public final void setI18NParameters(String messagePrefix, String baseBundleName)
      Sets the i18n parameters.
      Parameters:
      messagePrefix - The value for the message prefix.
      baseBundleName - The name of the base bundle.
    • setINIFileConfig

      public final void setINIFileConfig(String filename, boolean flag, String comment)
      Sets the configuration for the INI file.
      Parameters:
      filename - The path; can be null.
      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 be null.
    • setInitDataMethod

      public final void setInitDataMethod(MethodSpec method)
      Set the method that is provided as a source for the initialisation of the properties of the configuration bean.
      Parameters:
      method - The method; can be null.
    • setInitDataResource

      public final void setInitDataResource(String initDataResource)
      Set the name of the resource that is used to initialise the properties of the configuration bean.
      Parameters:
      initDataResource - The resource name; can be null.
    • setPreferenceChangeListenerClass

      public final void setPreferenceChangeListenerClass(TypeName listenerClass)
      Sets the class for the Preferences change listener.
      Parameters:
      listenerClass - The listener class; can be null.
      See Also:
    • setPreferencesRoot

      public final void setPreferencesRoot(String name)
      Sets the name for the preferences root node.
      Parameters:
      name - The name for the preferences root node.