Class MapConfiguration

java.lang.Object
is.galia.config.MapConfiguration
All Implemented Interfaces:
Configuration

public class MapConfiguration extends Object implements Configuration

Implementation backed by a Map.

Mutability and thread safety are dictated by the backing map.

  • Constructor Details

    • MapConfiguration

      public MapConfiguration()
      Initializes an instance with a new empty, mutable, thread-safe backing map.
    • MapConfiguration

      public MapConfiguration(Map<String,Object> backingMap)
      Enables the use of a custom backing map, essentially providing a facade to it.
      Parameters:
      backingMap - Backing map.
  • Method Details

    • clear

      public void clear()
      Description copied from interface: Configuration
      Clears any key-value pairs from the instance (but not its persistent store, if available).
      Specified by:
      clear in interface Configuration
    • clearProperty

      public void clearProperty(String key)
      Description copied from interface: Configuration
      Removes a single key-value pair from the instance (but not its persistent store, if available).
      Specified by:
      clearProperty in interface Configuration
      Parameters:
      key - Key to remove.
    • getBackingMap

      public Map<String,Object> getBackingMap()
    • getBoolean

      public boolean getBoolean(String key)
      Specified by:
      getBoolean in interface Configuration
    • getBoolean

      public boolean getBoolean(String key, boolean defaultValue)
      Specified by:
      getBoolean in interface Configuration
      Returns:
      Boolean value corresponding to the given key, or the given default value if the target value is null or cannot be coerced to a boolean.
    • getDouble

      public double getDouble(String key)
      Specified by:
      getDouble in interface Configuration
    • getDouble

      public double getDouble(String key, double defaultValue)
      Specified by:
      getDouble in interface Configuration
      Returns:
      Double value corresponding to the given key, or the given default value if the target value is null or cannot be coerced to a double.
    • getFile

      public Optional<Path> getFile()
      Specified by:
      getFile in interface Configuration
      Returns:
      The file backing the instance, if any.
    • getFloat

      public float getFloat(String key)
      Specified by:
      getFloat in interface Configuration
    • getFloat

      public float getFloat(String key, float defaultValue)
      Specified by:
      getFloat in interface Configuration
      Returns:
      Float value corresponding to the given key, or the given default value if the target value is null or cannot be coerced to a float.
    • getInt

      public int getInt(String key)
      Specified by:
      getInt in interface Configuration
    • getInt

      public int getInt(String key, int defaultValue)
      Specified by:
      getInt in interface Configuration
      Returns:
      Int value corresponding to the given key, or the given default value if the target value is null or cannot be coerced to an int.
    • getKeys

      public Iterator<String> getKeys()
      Specified by:
      getKeys in interface Configuration
      Returns:
      All keys contained in the configuration.
    • getLong

      public long getLong(String key)
      Specified by:
      getLong in interface Configuration
    • getLong

      public long getLong(String key, long defaultValue)
      Specified by:
      getLong in interface Configuration
      Returns:
      Long value corresponding to the given key, or the given default value if the target value is null or cannot be coerced to a long.
    • getProperty

      public Object getProperty(String key)
      Specified by:
      getProperty in interface Configuration
      Returns:
      Object value corresponding to the given key, or null if not set.
    • getString

      public String getString(String key)
      Specified by:
      getString in interface Configuration
      Returns:
      String value corresponding to the given key, or null if not set.
    • getString

      public String getString(String key, String defaultValue)
      Specified by:
      getString in interface Configuration
      Returns:
      String value corresponding to the given key, or the given default value if the target value is null.
    • reload

      public void reload()
      No-op.
      Specified by:
      reload in interface Configuration
    • setProperty

      public void setProperty(String key, Object value)
      Specified by:
      setProperty in interface Configuration