Package com.saperion.util.configuration
Class ConfigHolder
java.lang.Object
com.saperion.util.configuration.ConfigHolder
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given key-value pair to this holder.void
addAll
(Properties properties) Adds all properities contained in the given Properties object to this holder.Returns the value for the given key as an Object if existing.getAll()
Returns all properties of this holder as a Properties object.boolean
getAsBoolean
(String key, boolean defaultValue) Returns the value for the given key as a Boolean if existing.int
getAsInteger
(String key, int defaultValue) Returns the value for the given key as an Integer if existing.getAsString
(String key, String defaultValue) Returns the value for the given key as a String if existing.static ConfigHolder
Returns an instance of this class.
-
Field Details
-
configs
Configurations map.
-
-
Method Details
-
getInstance
Returns an instance of this class. Creates the instance if it is not existing yet.- Returns:
- The ConfigHolder instance.
-
addAll
Adds all properities contained in the given Properties object to this holder.- Parameters:
properties
- The Properties to hold.
-
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
Adds the given key-value pair to this holder.- Parameters:
key
- The key of the configuration.value
- The value of the configuration.
-
get
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
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
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
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
-