Package com.activeviam.properties
Class PropertyRegistry
java.lang.Object
com.activeviam.properties.PropertyRegistry
The registry of the ActiveViam properties.
This class was created to standardize how the properties are configured. Now a component needing to read the value of a property does not impose how it is set (with system property, environment property, Spring environment...).
By default, this class only retrieve properties defined as system or environment properties. To take into account properties defined in the Spring environment, one need to import SpringPropertyResolverConfig in the Spring Configuration.
- Author:
- ActiveViam
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear(ActiveViamProperty prop) Resets the value of a property.static booleangetBoolean(ActiveViamProperty prop, boolean defaultValue) Gets the value of the property ordefaultValueif it is not defined.static doublegetDouble(ActiveViamProperty prop, double defaultValue) Gets the value of the property ordefaultValueif it is not defined.static intgetInteger(ActiveViamProperty prop, int defaultValue) Gets the value of the property ordefaultValueif it is not defined.static longgetLong(ActiveViamProperty prop, long defaultValue) Gets the value of the property ordefaultValueif it is not defined.static booleanGets the value of the property.static doubleGets the value of the property.static intGets the value of the property.static longGets the value of the property.static StringGets the value of the property (nevernull).static StringgetString(ActiveViamProperty prop) Gets the value of the property ornullif it is not defined.static StringgetString(ActiveViamProperty prop, String defaultValue) Gets the value of the property ordefaultValueif it is not defined.static voidset(ActiveViamProperty prop, Object value) Sets the value of a property.
-
Method Details
-
getString
Gets the value of the property ordefaultValueif it is not defined.- Parameters:
prop- the property to resolvedefaultValue- the default value to return if no value is found- Returns:
- the value of the property or
defaultValueif it is not defined
-
getString
Gets the value of the property ornullif it is not defined.- Parameters:
prop- the property to resolve- Returns:
- the value of the property or
nullif it is not defined
-
getRequiredString
Gets the value of the property (nevernull).- Parameters:
prop- the property to resolve- Returns:
- the value of the property as a string
- Throws:
IllegalStateException- if the property is not defined
-
getBoolean
Gets the value of the property ordefaultValueif it is not defined.- Parameters:
prop- the property to resolvedefaultValue- the default value to return if no value is found- Returns:
- the value of the property or
defaultValueif it is not defined
-
getRequiredBoolean
Gets the value of the property.- Parameters:
prop- the property to resolve- Returns:
- the value of the property
- Throws:
IllegalStateException- if the property is not defined
-
getInteger
Gets the value of the property ordefaultValueif it is not defined.- Parameters:
prop- the property to resolvedefaultValue- the default value to return if no value is found- Returns:
- the value of the property or
defaultValueif it is not defined
-
getRequiredInteger
Gets the value of the property.- Parameters:
prop- the property to resolve- Returns:
- the value of the property
- Throws:
IllegalStateException- if the property is not defined
-
getDouble
Gets the value of the property ordefaultValueif it is not defined.- Parameters:
prop- the property to resolvedefaultValue- the default value to return if no value is found- Returns:
- the value of the property or
defaultValueif it is not defined
-
getRequiredDouble
Gets the value of the property.- Parameters:
prop- the property to resolve- Returns:
- the value of the property
- Throws:
IllegalStateException- if the property is not defined
-
getLong
Gets the value of the property ordefaultValueif it is not defined.- Parameters:
prop- the property to resolvedefaultValue- the default value to return if no value is found- Returns:
- the value of the property or
defaultValueif it is not defined
-
getRequiredLong
Gets the value of the property.- Parameters:
prop- the property to resolve- Returns:
- the value of the property
- Throws:
IllegalStateException- if the property is not defined
-
set
Sets the value of a property.- Parameters:
prop- the property to set in the registryvalue- value to set in the registry
-
clear
Resets the value of a property.- Parameters:
prop- the property to clear
-