Class StringMapConfiguration

All Implemented Interfaces:
Configuration

public class StringMapConfiguration extends AbstractStringConfiguration
Configuration implementation backed by a Map with string values.
Author:
Garret Wilson
See Also:
  • Constructor Details

    • StringMapConfiguration

      public StringMapConfiguration(@Nonnull Map<String,String> map)
      Map constructor.
      Parameters:
      map - The map to back this configuration.
      Throws:
      NullPointerException - if the given map is null.
  • Method Details

    • findSection

      public Optional<Section> findSection(String key) throws ConfigurationException
      Retrieves a section that may not be present.
      Implementation Specification:
      This implementation always returns Optional.empty(), as string maps do not support sections.
      Parameters:
      key - The configuration key.
      Returns:
      The optional section associated with the given key.
      Throws:
      ConfigurationException - if there is a configuration value stored in an invalid format.
    • hasConfigurationValueImpl

      protected boolean hasConfigurationValueImpl(String key) throws ConfigurationException
      Determines whether a configuration value is present in the underlying storage.

      The given configuration key is assumed to already be normalized, and should not be modified.

      This method must not fall back to parent configuration; only local values must be returned.

      Overrides:
      hasConfigurationValueImpl in class BaseConfiguration<String>
      Implementation Specification:
      This implementation delegates to Map.containsKey(Object).
      Parameters:
      key - The normalized configuration key.
      Returns:
      true if a value of any type could be retrieved from this configuration using the given key.
      Throws:
      ConfigurationException - if there is a configuration value stored in an invalid format.
    • findConfigurationValueImpl

      protected Optional<String> findConfigurationValueImpl(String key) throws ConfigurationException
      Implementation to retrieves a general configuration value that may not be present from the underlying storage.

      The given configuration key is assumed to already be normalized, and should not be modified.

      This method must not fall back to parent configuration; only local values must be returned.

      Specified by:
      findConfigurationValueImpl in class BaseConfiguration<String>
      Implementation Specification:
      This implementation delegates to Map.get(Object).
      Parameters:
      key - The normalized configuration key.
      Returns:
      The optional configuration value associated with the given key.
      Throws:
      ConfigurationException - if there is a configuration value stored in an invalid format.