Class ConfigurationDescriptionTools


  • public final class ConfigurationDescriptionTools
    extends Object
    Provides the functionality for the validation of configuration descriptions and configurations.
    • Method Detail

      • validateConfiguration

        public static org.apache.commons.configuration2.Configuration validateConfiguration​(org.apache.commons.configuration2.Configuration instConf,
                                                                                            Class<?> implementingClass,
                                                                                            String instanceName)
                                                                                     throws ConfigurationException
        Validates the given configuration against the ConfigurationDescription of the given class. If the given class and all of its ancestors are not annotated with ConfigurationDescription this method will just return.

        For missing values of configuration entries that are not marked as required their default value will be filled into the configuration. Please note that a property value is not considered missing as long as the default / anonymous instance provides a value for that property.

        Parameters:
        instConf - the configuration of an instance of the component
        implementingClass - the class implementing a component type (and potentially annotated with
        instanceName - the instance name is only needed to provide better messages in exceptions
        Returns:
        The instance configuration to allow for calling this method in a call to a super-constructor.
        Throws:
        ConfigurationException - if the configuration contained errors
      • validateConfiguration

        public static org.apache.commons.configuration2.Configuration validateConfiguration​(org.apache.commons.configuration2.Configuration instConf,
                                                                                            Class<?> implementingClass,
                                                                                            boolean includeIfaces,
                                                                                            String instanceName)
                                                                                     throws ConfigurationException
        Validates the given configuration against the ConfigurationDescription of the designated class its parent classes and optionally also its (parent) interfaces. If the designated class and all of its ancestors (possibly including interfaces) are not annotated with ConfigurationDescription this method will just return.

        For missing values of configuration entries that are not marked as required their default value will be filled into the configuration. Please note that a property value is not considered missing as long as the default / anonymous instance provides a value for that property.

        Parameters:
        instConf - the configuration of an instance of the component
        implementingClass - the class implementing a component type (and potentially annotated with
        includeIfaces - Whether to also validate the interfaces (and all parent interfaces) of the designated class.
        instanceName - the instance name is only needed to provide better messages in exceptions
        Returns:
        The instance configuration to allow for calling this method in a call to a super-constructor.
        Throws:
        ConfigurationException - if the configuration contained errors