Class Configuration

java.lang.Object
io.bdeploy.common.cfg.Configuration

public class Configuration extends Object
The Configuration is basically a wrapper around a Map which exposes access to the Map through Annotations.

Any arbitrary Annotation can be defined, including default values, and mapped to the Configuration using get(Class).

The mapped Annotation will access the underlying Map on every method call. If a key exists in the Map that corresponds to the name of the Annotation's Method, it will be converted to the target type and returned. Otherwise the default value of the Method is returned.

There is (limited) type conversion capabilities. Mainly this functionality exists to be able to map Strings (e.g. when mapping a command line using add(String...)) to the target types of the Annotation Methods.

  • Constructor Details

    • Configuration

      public Configuration()
  • Method Details

    • add

      public void add(String... arguments)
      Add a set of command line arguments to the mapping. Arguments must currently start with '--'.
      Parameters:
      arguments - the command line argument as passed to the program.
    • getAllRawObjects

      public Map<String,Object> getAllRawObjects()
    • add

      public void add(Properties properties)
      Adds arbitrary (String) properties to the mapping.

      Typically used to add a configuration file or system properties to the mapping

      Parameters:
      properties - the entries to add to the mapping.
    • get

      public <T extends Annotation> T get(Class<? extends Annotation> target)
      Returns an instance of the given Annotation, mapping each Method to a value in the mapping where the Method name is the key into the wrapped Map.
      Parameters:
      target - the Class to map this Configuration to.
      Returns:
      a proxy mapping to the Configuration.
    • cast

      public static <T> T cast(Object object)
    • formatHelp

      public static void formatHelp(Class<? extends Annotation> cfg, DataTable target)
      Analyze Configuration.Help annotations on the target Annotation and print out help information on the given PrintStream.