Class ConfigurationDescriptionTools
- java.lang.Object
-
- de.aristaflow.adept2.base.configuration.ConfigurationDescriptionTools
-
public final class ConfigurationDescriptionTools extends Object
Provides the functionality for the validation ofconfiguration descriptions and configurations.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.apache.commons.configuration2.ConfigurationvalidateConfiguration(org.apache.commons.configuration2.Configuration instConf, Class<?> implementingClass, boolean includeIfaces, String instanceName)Validates the given configuration against theConfigurationDescriptionof the designated class its parent classes and optionally also its (parent) interfaces.static org.apache.commons.configuration2.ConfigurationvalidateConfiguration(org.apache.commons.configuration2.Configuration instConf, Class<?> implementingClass, String instanceName)Validates the given configuration against theConfigurationDescriptionof the given class.static voidvalidateConfigurationDescription(Class<?> implementingClass)Validates theConfigurationDescriptionof the given class including its subclasses.
-
-
-
Method Detail
-
validateConfigurationDescription
public static void validateConfigurationDescription(Class<?> implementingClass) throws IllegalConfigurationDescriptionException
Validates theConfigurationDescriptionof the given class including its subclasses. This does not include interfaces!- Parameters:
implementingClass- the class implementing a component type (and potentially annotated (or its ancestor classes) withConfigurationDescription)- Throws:
IllegalConfigurationDescriptionException- if the configuration descriptions contains inherent errors, like a default value that doesn't match the specified type of a property or aConfigurationValidatorthat can't be instantiated
-
validateConfiguration
public static org.apache.commons.configuration2.Configuration validateConfiguration(org.apache.commons.configuration2.Configuration instConf, Class<?> implementingClass, String instanceName) throws ConfigurationExceptionValidates the given configuration against theConfigurationDescriptionof the given class. If the given class and all of its ancestors are not annotated withConfigurationDescriptionthis 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 componentimplementingClass- the class implementing a component type (and potentially annotated withinstanceName- 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 ConfigurationExceptionValidates the given configuration against theConfigurationDescriptionof 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 withConfigurationDescriptionthis 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 componentimplementingClass- the class implementing a component type (and potentially annotated withincludeIfaces- 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
-
-