Class ConfigManagerImpl

java.lang.Object
org.bytemechanics.config.manager.ConfigManagerImpl
All Implemented Interfaces:
ConfigManager

public class ConfigManagerImpl
extends java.lang.Object
implements ConfigManager
Config manager service implementation
Author:
afarre
  • Constructor Summary

    Constructors 
    Constructor Description
    ConfigManagerImpl​(java.lang.String... _locations)
    Config manager constructor using the default charset
    ConfigManagerImpl​(java.net.URI... _locations)
    Config manager constructor using the default charset
    ConfigManagerImpl​(java.nio.charset.Charset _charset, java.lang.String... _locations)
    Config manager constructor
    ConfigManagerImpl​(java.nio.charset.Charset _charset, java.net.URI... _locations)
    Config manager constructor
    ConfigManagerImpl​(java.util.List<java.net.URI> _locations, java.nio.charset.Charset _charset)
    Config manager constructor
  • Method Summary

    Modifier and Type Method Description
    java.nio.charset.Charset getCharset()
    Retrieve the effective charset (provided or default) to use loading configurations
    java.util.List<java.net.URI> getLocations()
    Retrieve the list of locations from where to load configurations
    void load()
    Reads all configured locations and populate into System properties
    java.util.stream.Stream<Config> read​(java.net.URI _location)
    Reads the uri location if possible returning a configuration stream
    protected java.util.stream.Stream<Config> read​(java.net.URI _location, java.io.Reader _reader)
    Read configuration from the given _reader population as stream
    java.util.stream.Stream<Config> stream()
    Reads all configured locations and return as stream
    protected void write​(java.net.URI _location, java.io.Writer _writer, java.util.stream.Stream<Config> _config)
    Write configuration to the given _writer from the given _config stream
    void write​(java.net.URI _location, java.util.stream.Stream<Config> _config)
    Utility method to update configuration locations when possible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConfigManagerImpl

      public ConfigManagerImpl​(java.util.List<java.net.URI> _locations, java.nio.charset.Charset _charset)
      Config manager constructor
      Parameters:
      _locations - list of URIs to load configurations
      _charset - charset to use to load the configurations
    • ConfigManagerImpl

      public ConfigManagerImpl​(java.nio.charset.Charset _charset, java.net.URI... _locations)
      Config manager constructor
      Parameters:
      _charset - charset to use to load the configurations
      _locations - list of URIs to load configurations
    • ConfigManagerImpl

      public ConfigManagerImpl​(java.nio.charset.Charset _charset, java.lang.String... _locations)
      Config manager constructor
      Parameters:
      _charset - charset to use to load the configurations
      _locations - list of locations to load configurations
    • ConfigManagerImpl

      public ConfigManagerImpl​(java.net.URI... _locations)
      Config manager constructor using the default charset
      Parameters:
      _locations - list of URIs to load configurations
    • ConfigManagerImpl

      public ConfigManagerImpl​(java.lang.String... _locations)
      Config manager constructor using the default charset
      Parameters:
      _locations - list of locations to load configurations
  • Method Details

    • getCharset

      public java.nio.charset.Charset getCharset()
      Retrieve the effective charset (provided or default) to use loading configurations
      Returns:
      effective charset
    • getLocations

      public java.util.List<java.net.URI> getLocations()
      Retrieve the list of locations from where to load configurations
      Returns:
      locations to load configurations
    • read

      protected java.util.stream.Stream<Config> read​(java.net.URI _location, java.io.Reader _reader)
      Read configuration from the given _reader population as stream
      Parameters:
      _location - configuration location to discern reader the format
      _reader - reader from where configuration must be readed
      Returns:
      stream of read configurations
      Throws:
      UnsupportedConfigLocationFormat - if the format of the location is not supported
      java.lang.NullPointerException - if any of parameters are null
    • write

      protected void write​(java.net.URI _location, java.io.Writer _writer, java.util.stream.Stream<Config> _config)
      Write configuration to the given _writer from the given _config stream
      Parameters:
      _location - configuration location to discern reader the format
      _writer - writer where configuration must be write down
      _config - configuration to be writen
      Throws:
      UnwritableConfigLocation - when for any reason the configuration can not be writen
      UnsupportedConfigLocationFormat - if the format of the location is not supported
      java.lang.UnsupportedOperationException - if write operation is not supported by the location format and/or scheme
      java.lang.NullPointerException - if any of parameters are null
    • read

      public java.util.stream.Stream<Config> read​(java.net.URI _location)
      Description copied from interface: ConfigManager
      Reads the uri location if possible returning a configuration stream
      Specified by:
      read in interface ConfigManager
      Parameters:
      _location - location where read the configuration
      Returns:
      Stream of configurations or an empty stream
      See Also:
      ConfigManager.read(java.net.URI)
    • write

      public void write​(java.net.URI _location, java.util.stream.Stream<Config> _config)
      Description copied from interface: ConfigManager
      Utility method to update configuration locations when possible
      Specified by:
      write in interface ConfigManager
      Parameters:
      _location - location to update/create configuration
      _config - stream of config files to write
      See Also:
      ConfigManager.write(java.net.URI, java.util.stream.Stream)
    • stream

      public java.util.stream.Stream<Config> stream()
      Description copied from interface: ConfigManager
      Reads all configured locations and return as stream
      Specified by:
      stream in interface ConfigManager
      Returns:
      Stream of configurations or an empty stream
      See Also:
      ConfigManager.stream()
    • load

      public void load()
      Description copied from interface: ConfigManager
      Reads all configured locations and populate into System properties
      Specified by:
      load in interface ConfigManager
      See Also:
      ConfigManager.load()