Class ConfigMap
- java.lang.Object
-
- uk.ac.starlink.ttools.plot2.config.ConfigMap
-
- Direct Known Subclasses:
LoggingConfigMap
@Equality public class ConfigMap extends java.lang.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:
ConfigKey
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
<T> T
get(ConfigKey<T> key)
Reads the value associated with a given key.int
hashCode()
java.util.Set<ConfigKey<?>>
keySet()
Returns a set view of the keys explicitly written into the map.<T> void
put(ConfigKey<T> key, T value)
Puts an entry into this map.void
putAll(ConfigMap config)
Copies all the entries from a given map into this map.java.lang.String
toString()
-
-
-
Constructor Detail
-
ConfigMap
public ConfigMap()
Constructs an empty map.
-
ConfigMap
public ConfigMap(ConfigMap copy)
Copy constructor.- Parameters:
copy
- map to copy
-
-
Method Detail
-
put
public <T> void put(ConfigKey<T> key, T value)
Puts an entry into this map.- Parameters:
key
- keyvalue
- 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 java.util.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:
Map.keySet()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-