Package com.activeviam.properties
Class PropertyRegistry
- java.lang.Object
-
- com.activeviam.properties.PropertyRegistry
-
public class PropertyRegistry extends Object
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
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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 booleangetRequiredBoolean(ActiveViamProperty prop)Gets the value of the property.static doublegetRequiredDouble(ActiveViamProperty prop)Gets the value of the property.static intgetRequiredInteger(ActiveViamProperty prop)Gets the value of the property.static longgetRequiredLong(ActiveViamProperty prop)Gets the value of the property.static StringgetRequiredString(ActiveViamProperty prop)Gets 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 Detail
-
getString
public static String getString(ActiveViamProperty prop, String defaultValue)
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
public static String getString(ActiveViamProperty prop)
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
public static String getRequiredString(ActiveViamProperty prop) throws IllegalStateException
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
public static boolean getBoolean(ActiveViamProperty prop, boolean defaultValue)
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
public static boolean getRequiredBoolean(ActiveViamProperty prop) throws IllegalStateException
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
public static int getInteger(ActiveViamProperty prop, int defaultValue)
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
public static int getRequiredInteger(ActiveViamProperty prop) throws IllegalStateException
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
public static double getDouble(ActiveViamProperty prop, double defaultValue)
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
public static double getRequiredDouble(ActiveViamProperty prop) throws IllegalStateException
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
public static long getLong(ActiveViamProperty prop, long defaultValue)
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
public static long getRequiredLong(ActiveViamProperty prop) throws IllegalStateException
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
public static void set(ActiveViamProperty prop, Object value)
Sets the value of a property.- Parameters:
prop- the property to set in the registryvalue- value to set in the registry
-
clear
public static void clear(ActiveViamProperty prop)
Resets the value of a property.- Parameters:
prop- the property to clear
-
-