Module utilities

Class Configuration

java.lang.Object
de.grogra.util.Configuration
All Implemented Interfaces:
Map, ModifiableMap

public final class Configuration extends Object implements ModifiableMap
A Configuration is a ModifiableMap which uses Strings as keys and maintains three levels of associations:
  1. The basic level is represented by default values and is not modified by methods of this class.
  2. The next level overrides the basic level, it is defined by the override methods.
  3. The third level overrides the other levels, it is defined by the put method.
Author:
Ole Kniemeyer
  • Constructor Details

    • Configuration

      public Configuration(KeyDescription[] keys, Map values)
      Creates a new Configuration. Its keys are described by keys, its default values by the map values.
      Parameters:
      keys - the keys of this configuration
      values - the default values of this configuration
  • Method Details

    • put

      public Object put(Object key, Object value)
      Description copied from interface: ModifiableMap
      Maps key to value. Following invocations of the get-method with key as key will return value.
      Specified by:
      put in interface ModifiableMap
      Parameters:
      key - a key
      value - the value to be associated with key
      Returns:
      the previously associated value, or null
    • override

      public void override(String key, Object value)
      Overrides default values of this configuration.
      Parameters:
      key - a key
      value - the new default value for key
    • overrideIfUnset

      public void overrideIfUnset(String key, Object value)
      Sets a default value if no default value is provided by the map for default values.
      Parameters:
      key - a key
      value - the default value for key
    • get

      public Object get(Object key, Object defaultValue)
      Description copied from interface: Map
      Returns the value associated with key. If there is no value associated with key, defaultValue is returned.
      Specified by:
      get in interface Map
      Parameters:
      key - a key for the map
      defaultValue - the default value
      Returns:
      the associated value, or defaultValue
    • writeBack

      public void writeBack()