Class ConfigurationSourceProperties

All Implemented Interfaces:
IConfigurationSource, IIterableConfigurationSource, IConfigurationSourceResource, IConfigurationValueProvider

@ThreadSafe public class ConfigurationSourceProperties extends AbstractConfigurationSourceResource
Implementation of IConfigurationSource for properties file based configuration sources.
Author:
Philip Helger
  • Field Details

  • Constructor Details

    • ConfigurationSourceProperties

      public ConfigurationSourceProperties(@Nonnull com.helger.io.resource.IReadableResource aRes)
      Constructor with default priority and default charset
      Parameters:
      aRes - Resource to read from. May not be null.
    • ConfigurationSourceProperties

      public ConfigurationSourceProperties(@Nonnull com.helger.io.resource.IReadableResource aRes, @Nullable Charset aCharset)
      Constructor with default priority
      Parameters:
      aRes - Resource to read from. May not be null.
      aCharset - Character set to use. May be null.
    • ConfigurationSourceProperties

      public ConfigurationSourceProperties(int nPriority, @Nonnull com.helger.io.resource.IReadableResource aRes)
      Constructor with default charset
      Parameters:
      nPriority - Configuration source priority.
      aRes - Resource to read from. May not be null.
    • ConfigurationSourceProperties

      public ConfigurationSourceProperties(int nPriority, @Nonnull com.helger.io.resource.IReadableResource aRes, @Nullable Charset aCharset)
      Constructor
      Parameters:
      nPriority - Configuration source priority.
      aRes - Resource to read from. May not be null.
      aCharset - Character set to use. May be null.
  • Method Details

    • getCharset

      @Nullable public Charset getCharset()
      Returns:
      The charset used to load the properties. May be null.
    • isInitializedAndUsable

      public boolean isInitializedAndUsable()
      Returns:
      true if the file was successfully initialized and can be used as a configuration source.
    • reload

      @Nonnull public com.helger.base.state.ESuccess reload()
      Description copied from interface: IConfigurationSourceResource
      Try to reload the configuration source from the configured resource. The reloading should be an atomic operation and be thread-safe.
      Returns:
      ESuccess.SUCCESS if the resource was found and loaded, ESuccess.FAILURE otherwise.
    • getConfigurationValue

      @Nullable public ConfiguredValue getConfigurationValue(@Nonnull @Nonempty String sKey)
      Description copied from interface: IConfigurationValueProvider
      Get the configuration value with the provided key.
      Parameters:
      sKey - The key to be retrieved. May neither be null nor empty.
      Returns:
      null if no such value is available.
    • getAllConfigItems

      @Nonnull @ReturnsMutableCopy public com.helger.collection.commons.ICommonsOrderedMap<String,String> getAllConfigItems()
      Returns:
      An ordered map of all contained keys and values in this resource. The order of the items should follow the order of their declaration in the underlying resource. Never null but maybe empty.
    • equals

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

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

      public String toString()
      Overrides:
      toString in class AbstractConfigurationSourceResource