Class ConfigurationDescriptionTools

java.lang.Object
de.aristaflow.adept2.base.configuration.ConfigurationDescriptionTools

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

    • validateConfigurationDescription

      public static void validateConfigurationDescription(Class<?> implementingClass) throws IllegalConfigurationDescriptionException
      Validates the ConfigurationDescription of 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) with ConfigurationDescription)
      Throws:
      IllegalConfigurationDescriptionException - if the configuration descriptions contains inherent errors, like a default value that doesn't match the specified type of a property or a ConfigurationValidator that can't be instantiated
    • validateConfiguration

      public static Configuration validateConfiguration(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 Configuration validateConfiguration(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