Class ConfigHolder

java.lang.Object
com.saperion.util.configuration.ConfigHolder

public final class ConfigHolder extends Object
This class is a singleton configuration holder. Once the configuration settings are set they will be available for the rest of the application as long as the application itself runs.
Author:
sts
  • Field Details

  • Method Details

    • getInstance

      public static ConfigHolder getInstance()
      Returns an instance of this class. Creates the instance if it is not existing yet.
      Returns:
      The ConfigHolder instance.
    • addAll

      public void addAll(Properties properties)
      Adds all properities contained in the given Properties object to this holder.
      Parameters:
      properties - The Properties to hold.
    • getAll

      public Properties getAll()
      Returns all properties of this holder as a Properties object. Manipulations on the returned Properties object do not affect this holders properties.
      Returns:
      properties of this holder.
    • add

      public void add(String key, Object value)
      Adds the given key-value pair to this holder.
      Parameters:
      key - The key of the configuration.
      value - The value of the configuration.
    • get

      public Object get(String key, Object defaultValue)
      Returns the value for the given key as an Object if existing. Otherwise the given default value is returned.
      Parameters:
      key - The key for the configuration value to get.
      defaultValue - The default value if the configuration is not existing.
      Returns:
      the value for the given key as an Object if existing. Otherwise the given default value is returned.
    • getAsBoolean

      public boolean getAsBoolean(String key, boolean defaultValue)
      Returns the value for the given key as a Boolean if existing. Otherwise the given default value is returned.
      Parameters:
      key - The key for the configuration value to get.
      defaultValue - default value if the configuration is not existing.
      Returns:
      the value for the given key as a Boolean if existing. Otherwise the given default value is returned.
    • getAsInteger

      public int getAsInteger(String key, int defaultValue)
      Returns the value for the given key as an Integer if existing. Otherwise the given default value is returned.
      Parameters:
      key - The key for the configuration value to get.
      defaultValue - default value if the configuration is not existing.
      Returns:
      the value for the given key as an Integer if existing. Otherwise the given default value is returned.
    • getAsString

      public String getAsString(String key, String defaultValue)
      Returns the value for the given key as a String if existing. Otherwise the given default value is returned.
      Parameters:
      key - The key for the configuration value to get.
      defaultValue - default value if the configuration is not existing.
      Returns:
      the value for the given key as a String if existing. Otherwise the given default value is returned.
    • printCurrentConfigs

      public String printCurrentConfigs()