Class ConfigMap

java.lang.Object
uk.ac.starlink.ttools.plot2.config.ConfigMap
Direct Known Subclasses:
LoggingConfigMap

@Equality public class ConfigMap extends Object
Map containing typed configuration keys.

Missing entries for a key are for most purposes treated as if the key is present with its default value. Null values may however be placed explicitly into the map.

Null keys are not supported.

Concurrency requirements: this map will get written in one thread (perhaps the Event Dispatch Thread), and after writing is complete may be concurrently in the same and different threads.

Since:
22 Feb 2013
Author:
Mark Taylor
See Also:
  • Constructor Details

    • ConfigMap

      public ConfigMap()
      Constructs an empty map.
    • ConfigMap

      public ConfigMap(ConfigMap copy)
      Copy constructor.
      Parameters:
      copy - map to copy
  • Method Details

    • put

      public <T> void put(ConfigKey<T> key, T value)
      Puts an entry into this map.
      Parameters:
      key - key
      value - value to associate with key
    • putAll

      public void putAll(ConfigMap config)
      Copies all the entries from a given map into this map.
      Parameters:
      config - map to copy
    • get

      public <T> T get(ConfigKey<T> key)
      Reads the value associated with a given key. If the key is not present in the map, the default value for that key is returned.
      Parameters:
      key - key
      Returns:
      value earlier written to map, or default value
    • keySet

      public Set<ConfigKey<?>> keySet()
      Returns a set view of the keys explicitly written into the map. Note that non-null (default) values may be read from the map even for keys absent from this set.
      Returns:
      set of keys backed by map; supports removal operations
      See Also:
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object