Class ParametersService

java.lang.Object
org.tkit.onecx.quarkus.parameter.ParametersService

@ApplicationScoped public class ParametersService extends Object
  • Constructor Details

    • ParametersService

      public ParametersService()
  • Method Details

    • init

      public void init(ParametersConfig parametersConfig, String applicationId)
      Initialize the cache and parameters client
      Parameters:
      parametersConfig - the parameters management configuration
    • getValue

      public <T> T getValue(String propertyName, Class<T> propertyType, String defaultValue)
      Return the resolved property value with the specified type for the specified property name from the underlying configuration sources.

      The configuration value is not guaranteed to be cached by the implementation, and may be expensive to compute; therefore, if the returned value is intended to be frequently used, callers should consider storing rather than recomputing it.

      Type Parameters:
      T - The property type
      Parameters:
      propertyName - The configuration property name
      propertyType - The type into which the resolved property value should get converted
      defaultValue - The default value to return if the property value could not get resolved
      Returns:
      the resolved property value as an instance of the requested type
      Throws:
      IllegalArgumentException - if the property cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration
    • getValue

      public <T> T getValue(String propertyName, Class<T> propertyType)
      Return the resolved property value with the specified type for the specified property name from the underlying configuration sources.

      The configuration value is not guaranteed to be cached by the implementation, and may be expensive to compute; therefore, if the returned value is intended to be frequently used, callers should consider storing rather than recomputing it.

      This is a shortcut to the getValue method using null as defaultValue.

      Type Parameters:
      T - The property type
      Parameters:
      propertyName - The configuration property name
      propertyType - The type into which the resolved property value should get converted
      Returns:
      the resolved property value as an instance of the requested type
      Throws:
      IllegalArgumentException - if the property cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration