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 Details

    • getString

      public static String getString(ActiveViamProperty prop, String defaultValue)
      Gets the value of the property or defaultValue if it is not defined.
      Parameters:
      prop - the property to resolve
      defaultValue - the default value to return if no value is found
      Returns:
      the value of the property or defaultValue if it is not defined
    • getString

      public static String getString(ActiveViamProperty prop)
      Gets the value of the property or null if it is not defined.
      Parameters:
      prop - the property to resolve
      Returns:
      the value of the property or null if it is not defined
    • getRequiredString

      public static String getRequiredString(ActiveViamProperty prop) throws IllegalStateException
      Gets the value of the property (never null).
      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 or defaultValue if it is not defined.
      Parameters:
      prop - the property to resolve
      defaultValue - the default value to return if no value is found
      Returns:
      the value of the property or defaultValue if 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 or defaultValue if it is not defined.
      Parameters:
      prop - the property to resolve
      defaultValue - the default value to return if no value is found
      Returns:
      the value of the property or defaultValue if 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 or defaultValue if it is not defined.
      Parameters:
      prop - the property to resolve
      defaultValue - the default value to return if no value is found
      Returns:
      the value of the property or defaultValue if 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 or defaultValue if it is not defined.
      Parameters:
      prop - the property to resolve
      defaultValue - the default value to return if no value is found
      Returns:
      the value of the property or defaultValue if 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 registry
      value - 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