Class SmallRyeConfig

java.lang.Object
io.smallrye.config.SmallRyeConfig
All Implemented Interfaces:
Serializable, org.eclipse.microprofile.config.Config

public class SmallRyeConfig extends Object implements org.eclipse.microprofile.config.Config, Serializable
SmallRyeConfig provides a way to retrieve configuration values from a configuration name.

A SmallRyeConfig instance is obtained via the SmallRyeConfigBuilder.build(), which details how SmallRyeConfig will behave. Generally, a SmallRyeConfig instance is composed of:

  • Configuration Sources to lookup the configuration values
  • Converters to convert values to specific types
  • Interceptors to enhance the configuration lookup process
  • ConfigMapping Config Mappings classes to group multiple configuration values in a common prefix
Author:
Jeff Mesnil, David M. Lloyd, Roberto Cortez
See Also:
  • Field Details

    • SMALLRYE_CONFIG_PROFILE

      public static final String SMALLRYE_CONFIG_PROFILE
      Configuration name to set the main Profiles to activate. The configuration supports multiple profiles separated by a comma.
      See Also:
    • SMALLRYE_CONFIG_PROFILE_PARENT

      public static final String SMALLRYE_CONFIG_PROFILE_PARENT
      Configuration name to set the parent Profile to activate.
      See Also:
    • SMALLRYE_CONFIG_LOCATIONS

      public static final String SMALLRYE_CONFIG_LOCATIONS
      Configuration name to set additional config locations to be loaded with the Config. The configuration supports multiple locations separated by a comma and each must represent a valid java.net.URI.
      See Also:
    • SMALLRYE_CONFIG_MAPPING_VALIDATE_UNKNOWN

      public static final String SMALLRYE_CONFIG_MAPPING_VALIDATE_UNKNOWN
      Configuration name to validate that a ConfigMapping maps every available configuration name contained in the mapping prefix. The configuration value must be a boolean.
      See Also:
    • SMALLRYE_CONFIG_SECRET_HANDLERS

      public static final String SMALLRYE_CONFIG_SECRET_HANDLERS
      Configuration name to set the names of the secret handlers to be loaded. A value of all loads all available secret handlers and a value of none skips the load. The configuration supports multiple secret handlers separated by a comma.
      See Also:
    • SMALLRYE_CONFIG_LOG_VALUES

      public static final String SMALLRYE_CONFIG_LOG_VALUES
      Configuration name to enable logging of configuration values lookup in DEBUG log level. The configuration value must be a boolean.
      See Also:
  • Method Details

    • getValues

      public <T> List<T> getValues(String name, Class<T> propertyType)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for indexed properties. An indexed property uses the original property name with square brackets and an index in between, as my.property[0]. All indexed properties are queried for their value, which represents a single element in the returning List converted to their specified property type. The following configuration:

      • my.property[0]=dog
      • my.property[1]=cat
      • my.property[2]=turtle

      Results in a List with the elements dog, cat, and turtle, considering the configuration name as my.property and the property type as a String.

      Otherwise, the configuration value is a single element that a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration of my.property=dog,cat,turtle results in a List with the elements dog, cat, and turtle, considering the configuration name as my.property and the property type as a String.

      The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Specified by:
      getValues in interface org.eclipse.microprofile.config.Config
      Type Parameters:
      T - the item type
      Parameters:
      name - The configuration property name to look for in the configuration
      propertyType - The type into which the resolved property values are converted
      Returns:
      the resolved property values as a List of instances of the property type
      Throws:
      IllegalArgumentException - if the property values cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration or is defined as an empty string, or the converter returns null
      See Also:
    • getValues

      public <T, C extends Collection<T>> C getValues(String name, Class<T> itemClass, IntFunction<C> collectionFactory)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for indexed properties. An indexed property uses the original property name with square brackets and an index in between, as my.property[0]. All indexed properties are queried for their value, which represents a single element in the returning Collection converted to their specified property type. The following configuration:

      • my.property[0]=dog
      • my.property[1]=cat
      • my.property[2]=turtle

      Results in a Collection with the elements dog, cat, and turtle, considering the configuration name as my.property and the property type as a String.

      Otherwise, the configuration value is a single element that a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration of my.property=dog,cat,turtle results in a Collection with the elements dog, cat, and turtle, considering the configuration name as my.property and the property type as a String.

      The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      T - the item type
      C - the collection type
      Parameters:
      name - The configuration property name to look for in the configuration
      itemClass - The type into which the resolved property values are converted
      collectionFactory - the resulting instance of a Collection to return the property values
      Returns:
      the resolved property values as a Collection of instances of the property type
      Throws:
      IllegalArgumentException - if the property values cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration or is defined as an empty string, or the converter returns null
      See Also:
    • getValues

      public <T, C extends Collection<T>> C getValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for indexed properties. An indexed property uses the original property name with square brackets and an index in between, as my.property[0]. All indexed properties are queried for their value, which represents a single element in the returning Collection converted by the specified Converter. The following configuration:

      • my.property[0]=dog
      • my.property[1]=cat
      • my.property[2]=turtle

      Results in a Collection with the elements dog, cat, and turtle, considering the configuration name as my.property and the property type as a String.

      Otherwise, the configuration value is a single element that a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration of my.property=dog,cat,turtle results in a Collection with the elements dog, cat, and turtle, considering the configuration name as my.property and the Converter to convert the property type as a String.

      The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      T - the item type
      C - the collection type
      Parameters:
      name - The configuration property name to look for in the configuration
      converter - The Converter to use to convert the resolved property values
      collectionFactory - the resulting instance of a Collection to return the property values
      Returns:
      the resolved property values as a Collection of instances of the property type
      Throws:
      IllegalArgumentException - if the property values cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration or is defined as an empty string, or the converter returns null
      See Also:
    • getIndexedValues

      @Deprecated(forRemoval=true) public <T, C extends Collection<T>> C getIndexedValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getIndexedProperties

      public List<String> getIndexedProperties(String property)
    • getIndexedPropertiesIndexes

      public List<Integer> getIndexedPropertiesIndexes(String property)
    • getValues

      public <K, V> Map<K,V> getValues(String name, Class<K> keyClass, Class<V> valueClass)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for keyed properties. A keyed property uses the original property name plus an additional dotted segment to represent a Map key, as my.property.key, where my.property is the property name and key is the Map key. All keyed properties are queried for their values, which represent a single entry in the returning Map converting both the key and value to their specified types. The following configuration:

      • server.reasons.200=OK
      • server.reasons.201=CREATED
      • server.reasons.404=NOT_FOUND

      Results in a Map with the entries 200=OK, 201=CREATED, and 404=NOT_FOUND, considering the configuration name as server.reasons, the key type as Integer and the property type as a String.

      Otherwise, the configuration value is a single element represented by key value pairs as <key1>=<value1>;<key2>=<value2>... separated by a semicolon ; with the backslash (\) as the escape character. A configuration of server.reasons=200=OK;201=CREATED;404=NOT_FOUND results in a Map with the entries 200=OK, 201=CREATED, and 404=NOT_FOUND, considering the configuration name as server.reasons, the key type as Integer and the property type as a String.

      The keyed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      name - The configuration property name to look for in the configuration
      keyClass - The type into which the resolved property keys are converted
      valueClass - The type into which the resolved property values are converted
      Returns:
      the resolved property values as a Map of keys of the property name and values of the property type
      Throws:
      IllegalArgumentException - if the property keys or values cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration or is defined as an empty string, or the converter returns null
      See Also:
    • getValues

      public <K, V> Map<K,V> getValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for keyed properties. A keyed property uses the original property name plus an additional dotted segment to represent a Map key, as my.property.key, where my.property is the property name and key is the Map key. All keyed properties are queried for their values, which represent a single entry in the returning Map converting both the key and value using the specified Converters. The following configuration:

      • server.reasons.200=OK
      • server.reasons.201=CREATED
      • server.reasons.404=NOT_FOUND

      Results in a Map with the entries 200=OK, 201=CREATED, and 404=NOT_FOUND, considering the configuration name as server.reasons and Converters to convert the key type as an Integer and the property type as a String.

      Otherwise, the configuration value is a single element represented by key value pairs as <key1>=<value1>;<key2>=<value2>... separated by a semicolon ; with the backslash (\) as the escape character. A configuration of server.reasons=200=OK;201=CREATED;404=NOT_FOUND results in a Map with the entries 200=OK, 201=CREATED, and 404=NOT_FOUND, considering the configuration name as server.reasons and Converters to convert the key type as an Integer and the property type as a String.

      The keyed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      name - The configuration property name to look for in the configuration
      keyConverter - The Converter to use to convert the resolved property keys
      valueConverter - The Converter to use to convert the resolved property values
      Returns:
      the resolved property values as a Map of keys of the property name and values of the property type
      Throws:
      IllegalArgumentException - if the property keys or values cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration or is defined as an empty string, or the converter returns null
      See Also:
    • getValues

      public <K, V> Map<K,V> getValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter, IntFunction<Map<K,V>> mapFactory)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for keyed properties. A keyed property uses the original property name plus an additional dotted segment to represent a Map key, as my.property.key, where my.property is the property name and key is the Map key. All keyed properties are queried for their values, which represent a single entry in the returning Map converting both the key and value using the specified Converters. The following configuration:

      • server.reasons.200=OK
      • server.reasons.201=CREATED
      • server.reasons.404=NOT_FOUND

      Results in a Map with the entries 200=OK, 201=CREATED, and 404=NOT_FOUND, considering the configuration name as server.reasons and Converters to convert the key type as an Integer and the property type as a String.

      Otherwise, the configuration value is a single element represented by key value pairs as <key1>=<value1>;<key2>=<value2>... separated by a semicolon ; with the backslash (\) as the escape character. A configuration of server.reasons=200=OK;201=CREATED;404=NOT_FOUND results in a Map with the entries 200=OK, 201=CREATED, and 404=NOT_FOUND, considering the configuration name as server.reasons and Converters to convert the key type as an Integer and the property type as a String.

      The keyed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      name - The configuration property name to look for in the configuration
      keyConverter - The Converter to use to convert the resolved property keys
      valueConverter - The Converter to use to convert the resolved property values
      mapFactory - the resulting instance of a Map to return the property keys and values
      Returns:
      the resolved property values as a Map of keys of the property name and values of the property type
      Throws:
      IllegalArgumentException - if the property keys or values cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration or is defined as an empty string, or the converter returns null
      See Also:
    • getValues

      public <K, V, C extends Collection<V>> Map<K,C> getValues(String name, Class<K> keyClass, Class<V> valueClass, IntFunction<C> collectionFactory)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for keyed indexed properties. A keyed indexed property uses the original property name plus an additional dotted segment to represent a Map key followed by square brackets and an index in between, as my.property.key[0], where my.property is the property name, key is the Map key and {code [0]} the index of the Collection element. All keyed indexed properties are queried for their value, which represent a single entry in the returning Map, and single element in the Collection value, converting both the key and value to their specified types. The following configuration:

      • server.env.prod[0]=alpha
      • server.env.prod[1]=beta
      • server.env.dev[0]=local

      Results in a Map with the entry key prod and entry value Collection with the values alpha and beta, and the entry key dev and entry value Collection with the value local, considering the configuration name as server.env, the key type as a String, and the property type as a String.

      Otherwise, the configuration value is a single element represented by key value pairs as <key1>=<value1>;<key2>=<value2>... separated by a semicolon ; and value as a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration of server.env=prod=alpha,beta;dev=local results in a Map with the entry key prod and entry value Collection with the values alpha and beta, and the entry key dev and entry value Collection with the value local, considering the configuration name as server.env, the key type as a String, and the property type as a String.

      The keyed indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      K - the key type
      V - the value type
      C - the collection type
      Parameters:
      name - The configuration property name to look for in the configuration
      keyClass - The type into which the resolved property keys are converted
      valueClass - The type into which the resolved property values are converted
      collectionFactory - the resulting instance of a Collection to return the property values
      Returns:
      the resolved property values as a Map of keys of the property name and values as a Collections of instances of the property type
      Throws:
      IllegalArgumentException - if the property keys or values cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration or is defined as an empty string, or the converter returns null
      See Also:
    • getValues

      public <K, V, C extends Collection<V>> Map<K,C> getValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter, IntFunction<Map<K,C>> mapFactory, IntFunction<C> collectionFactory)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for keyed indexed properties. A keyed indexed property uses the original property name plus an additional dotted segment to represent a Map key followed by square brackets and an index in between, as my.property.key[0], where my.property is the property name, key is the Map key and {code [0]} the index of the Collection element. All keyed indexed properties are queried for their value, which represent a single entry in the returning Map, and single element in the Collection value, converting both the key and value using the specified Converters. The following configuration:

      • server.env.prod[0]=alpha
      • server.env.prod[1]=beta
      • server.env.dev[0]=local

      Results in a Map with the entry key prod and entry value Collection with the values alpha and beta, and the entry key dev and entry value Collection with the value local, considering the configuration name as server.env and Converters to convert the key type as a String and the property type as a String.

      Otherwise, the configuration value is a single element represented by key value pairs as <key1>=<value1>;<key2>=<value2>... separated by a semicolon ; and value as a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration of server.env=prod=alpha,beta;dev=local results in a Map with the entry key prod and entry value Collection with the values alpha and beta, and the entry key dev and entry value Collection with the value local, considering the configuration name as server.env, and Converters to convert the key type as a String and the property type as a String.

      The keyed indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      K - the key type
      V - the value type
      C - the collection type
      Parameters:
      name - The configuration property name to look for in the configuration
      keyConverter - The Converter to use to convert the resolved property keys
      valueConverter - The Converter to use to convert the resolved property values
      mapFactory - the resulting instance of a Map to return the property keys and values
      collectionFactory - the resulting instance of a Collection to return the property values
      Returns:
      the resolved property values as a Map of keys of the property name and values as a Collections of instances of the property type
      Throws:
      IllegalArgumentException - if the property keys or values cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration or is defined as an empty string, or the converter returns null
      See Also:
    • getMapKeys

      public Map<String,String> getMapKeys(String name)
    • getMapIndexedKeys

      public Map<String,String> getMapIndexedKeys(String name)
    • getValue

      public <T> T getValue(String name, Class<T> propertyType)
      Returns the value for the specified configuration name from the underlying configuration sources.

      If the requested type is a type array, the lookup to the configuration will first query getPropertyNames() for indexed properties. An indexed property uses the original property name with square brackets and an index in between, as my.property[0]. All indexed properties are queried for their value, which represents a single element in the returning type array converted to their specified property type. The following configuration:

      • my.property[0]=dog
      • my.property[1]=cat
      • my.property[2]=turtle

      Results in an array with the elements dog, cat, and turtle, considering the configuration name as my.property and the property type as a String.

      Otherwise, the configuration value is a single element that a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration of my.property=dog,cat,turtle results in an array with the elements dog, cat, and turtle, considering the configuration name as my.property and the property type as a String.

      The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Specified by:
      getValue in interface org.eclipse.microprofile.config.Config
      Type Parameters:
      T - the property type
      Parameters:
      name - The configuration property name to look for in the configuration
      propertyType - The type into which the resolved property value is converted
      Returns:
      the resolved property value as an instance of the property type
      Throws:
      IllegalArgumentException - if the property values cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration or is defined as an empty string, or the converter returns null
      See Also:
    • getValue

      public <T> T getValue(String name, org.eclipse.microprofile.config.spi.Converter<T> converter)
      Returns the value for the specified configuration name from the underlying configuration sources.

      If the requested type is a type array, the lookup to the configuration will first query getPropertyNames() for indexed properties. An indexed property uses the original property name with square brackets and an index in between, as my.property[0]. All indexed properties are queried for their value, which represents a single element in the returning type array converted by the specified Converter. The following configuration:

      • my.property[0]=dog
      • my.property[1]=cat
      • my.property[2]=turtle

      Results in an array with the elements dog, cat, and turtle, considering the configuration name as my.property and the Converter to convert the property type as a String.

      Otherwise, the configuration value is a single element that a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration of my.property=dog,cat,turtle results in an array with the elements dog, cat, and turtle, considering the configuration name as my.property and the Converter to convert the property type as a String.

      The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      T - the property type
      Parameters:
      name - The configuration property name to look for in the configuration
      converter - The Converter to use to convert the resolved property value
      Returns:
      the resolved property value as an instance of the property type
      Throws:
      IllegalArgumentException - if the property values cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration or is defined as an empty string, or the converter returns null
      See Also:
    • convertValue

      public <T> T convertValue(ConfigValue configValue, org.eclipse.microprofile.config.spi.Converter<T> converter)
    • getConfigValue

      public ConfigValue getConfigValue(String name)
      Returns the ConfigValue for the specified configuration name from the underlying configuration sources.

      The lookup of the configuration is performed immediately, meaning that calls to ConfigValue will always yield the same results.

      A ConfigValue is always returned even if a property name cannot be found. In this case, every method in ConfigValue returns null, or the default value for primitive types, except for ConfigValue.getName(), which includes the original property name being looked up.

      Specified by:
      getConfigValue in interface org.eclipse.microprofile.config.Config
      Parameters:
      name - The configuration property name to look for in the configuration
      Returns:
      the resolved property value as a ConfigValue
    • getRawValue

      @Deprecated public String getRawValue(String name)
      Deprecated.
    • getOptionalValue

      public <T> Optional<T> getOptionalValue(String name, Class<T> propertyType)
      Returns the value for the specified configuration name from the underlying configuration sources.

      If the requested type is a type array, the lookup to the configuration will first query getPropertyNames() for indexed properties. An indexed property uses the original property name with square brackets and an index in between, as my.property[0]. All indexed properties are queried for their value, which represents a single element in the returning type array converted to their specified property type. The following configuration:

      • my.property[0]=dog
      • my.property[1]=cat
      • my.property[2]=turtle

      Results in an array with the elements dog, cat, and turtle, considering the configuration name as my.property and the property type as a String.

      Otherwise, the configuration value is a single element that a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration of my.property=dog,cat,turtle results in an array with the elements dog, cat, and turtle, considering the configuration name as my.property and the property type as a String.

      The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Specified by:
      getOptionalValue in interface org.eclipse.microprofile.config.Config
      Type Parameters:
      T - the property type
      Parameters:
      name - The configuration property name to look for in the configuration
      propertyType - The type into which the resolved property value is converted
      Returns:
      the resolved property value as a Optional instance of the property type
      Throws:
      IllegalArgumentException - if the property values cannot be converted to the specified type
      See Also:
    • getOptionalValue

      public <T> Optional<T> getOptionalValue(String name, org.eclipse.microprofile.config.spi.Converter<T> converter)
      Returns the value for the specified configuration name from the underlying configuration sources.

      If the requested type is a type array, the lookup to the configuration will first query getPropertyNames() for indexed properties. An indexed property uses the original property name with square brackets and an index in between, as my.property[0]. All indexed properties are queried for their value, which represents a single element in the returning type array converted by the specified Converter. The following configuration:

      • my.property[0]=dog
      • my.property[1]=cat
      • my.property[2]=turtle

      Results in an array with the elements dog, cat, and turtle, considering the configuration name as my.property and the Converter to convert the property type as a String.

      Otherwise, the configuration value is a single element that a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration of my.property=dog,cat,turtle results in an array with the elements dog, cat, and turtle, considering the configuration name as my.property and the Converter to convert the property type as a String.

      The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      T - the property type
      Parameters:
      name - The configuration property name to look for in the configuration
      converter - The Converter to use to convert the resolved property value
      Returns:
      the resolved property value as a Optional instance of the property type
      Throws:
      IllegalArgumentException - if the property values cannot be converted to the specified type
      See Also:
    • getOptionalValues

      public <T> Optional<List<T>> getOptionalValues(String name, Class<T> propertyType)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for indexed properties. An indexed property uses the original property name with square brackets and an index in between, as my.property[0]. All indexed properties are queried for their value, which represents a single element in the returning Optional<List> converted to their specified property type. The following configuration:

      • my.property[0]=dog
      • my.property[1]=cat
      • my.property[2]=turtle

      Results in an Optional<List> with the elements dog, cat, and turtle, considering the configuration name as my.property and the property type as a String.

      Otherwise, the configuration value is a single element that a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration of my.property=dog,cat,turtle results in a Optional<List> with the elements dog, cat, and turtle, considering the configuration name as my.property and the property type as a String.

      The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Specified by:
      getOptionalValues in interface org.eclipse.microprofile.config.Config
      Type Parameters:
      T - the item type
      Parameters:
      name - The configuration property name to look for in the configuration
      propertyType - The type into which the resolved property values are converted
      Returns:
      the resolved property values as a Optional<List> of instances of the property type
      Throws:
      IllegalArgumentException - if the property values cannot be converted to the specified type
      See Also:
    • getOptionalValues

      public <T, C extends Collection<T>> Optional<C> getOptionalValues(String name, Class<T> itemClass, IntFunction<C> collectionFactory)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for indexed properties. An indexed property uses the original property name with square brackets and an index in between, as my.property[0]. All indexed properties are queried for their value, which represents a single element in the returning Optional<Collection> converted to their specified property type. The following configuration:

      • my.property[0]=dog
      • my.property[1]=cat
      • my.property[2]=turtle

      Results in a Optional<Collection> with the elements dog, cat, and turtle, considering the configuration name as my.property and the property type as a String.

      Otherwise, the configuration value is a single element that a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration of my.property=dog,cat,turtle results in a Optional<Collection> with the elements dog, cat, and turtle, considering the configuration name as my.property and the property type as a String.

      The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      T - the item type
      C - the collection type
      Parameters:
      name - The configuration property name to look for in the configuration
      itemClass - The type into which the resolved property values are converted
      collectionFactory - the resulting instance of a Collection to return the property values
      Returns:
      the resolved property values as a Optional<Collection> of instances of the property type
      Throws:
      IllegalArgumentException - if the property values cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration or is defined as an empty string, or the converter returns null
      See Also:
    • getOptionalValues

      public <T, C extends Collection<T>> Optional<C> getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for indexed properties. An indexed property uses the original property name with square brackets and an index in between, as my.property[0]. All indexed properties are queried for their value, which represents a single element in the returning Optional<Collection> converted by the specified Converter. The following configuration:

      • my.property[0]=dog
      • my.property[1]=cat
      • my.property[2]=turtle

      Results in a Optional<Collection> with the elements dog, cat, and turtle, considering the configuration name as my.property and the property type as a String.

      Otherwise, the configuration value is a single element that a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration of my.property=dog,cat,turtle results in a Optional<Collection> with the elements dog, cat, and turtle, considering the configuration name as my.property and the property type as a String.

      The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      T - the item type
      C - the collection type
      Parameters:
      name - The configuration property name to look for in the configuration
      converter - The Converter to use to convert the resolved property values
      collectionFactory - the resulting instance of a Collection to return the property values
      Returns:
      the resolved property values as a Optional<Collection> of instances of the property type
      Throws:
      IllegalArgumentException - if the property values cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration or is defined as an empty string, or the converter returns null
      See Also:
    • getIndexedOptionalValues

      @Deprecated(forRemoval=true) public <T, C extends Collection<T>> Optional<C> getIndexedOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getOptionalValues

      public <K, V> Optional<Map<K,V>> getOptionalValues(String name, Class<K> keyClass, Class<V> valueClass)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for keyed properties. A keyed property uses the original property name plus an additional dotted segment to represent a Map key, as my.property.key, where my.property is the property name and key is the Map key. All keyed properties are queried for their values, which represent a single entry in the returning Optional<Map> converting both the key and value to their specified types. The following configuration:

      • server.reasons.200=OK
      • server.reasons.201=CREATED
      • server.reasons.404=NOT_FOUND

      Results in a Optional<Map> with the entries 200=OK, 201=CREATED, and 404=NOT_FOUND, considering the configuration name as server.reasons, the key type as Integer and the property type as a String.

      Otherwise, the configuration value is a single element represented by key value pairs as <key1>=<value1>;<key2>=<value2>... separated by a semicolon ; with the backslash (\) as the escape character. A configuration of server.reasons=200=OK;201=CREATED;404=NOT_FOUND results in a Optional<Map> with the entries 200=OK, 201=CREATED, and 404=NOT_FOUND, considering the configuration name as server.reasons, the key type as Integer and the property type as a String.

      The keyed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      name - The configuration property name to look for in the configuration
      keyClass - The type into which the resolved property keys are converted
      valueClass - The type into which the resolved property values are converted
      Returns:
      the resolved property values as a Optional<Map> of keys of the property name and values of the property type
      Throws:
      IllegalArgumentException - if the property keys or values cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration or is defined as an empty string, or the converter returns null
      See Also:
    • getOptionalValues

      public <K, V> Optional<Map<K,V>> getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for keyed properties. A keyed property uses the original property name plus an additional dotted segment to represent a Map key, as my.property.key, where my.property is the property name and key is the Map key. All keyed properties are queried for their values, which represent a single entry in the returning Optional<Map> converting both the key and value using the specified Converters. The following configuration:

      • server.reasons.200=OK
      • server.reasons.201=CREATED
      • server.reasons.404=NOT_FOUND

      Results in a Optional<Map> with the entries 200=OK, 201=CREATED, and 404=NOT_FOUND, considering the configuration name as server.reasons and Converters to convert the key type as an Integer and the property type as a String.

      Otherwise, the configuration value is a single element represented by key value pairs as <key1>=<value1>;<key2>=<value2>... separated by a semicolon ; with the backslash (\) as the escape character. A configuration of server.reasons=200=OK;201=CREATED;404=NOT_FOUND results in a Optional<Map> with the entries 200=OK, 201=CREATED, and 404=NOT_FOUND, considering the configuration name as server.reasons and Converters to convert the key type as an Integer and the property type as a String.

      The keyed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      name - The configuration property name to look for in the configuration
      keyConverter - The Converter to use to convert the resolved property keys
      valueConverter - The Converter to use to convert the resolved property values
      Returns:
      the resolved property values as a Optional<Map> of keys of the property name and values of the property type
      Throws:
      IllegalArgumentException - if the property keys or values cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration or is defined as an empty string, or the converter returns null
      See Also:
    • getOptionalValues

      public <K, V> Optional<Map<K,V>> getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter, IntFunction<Map<K,V>> mapFactory)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for keyed properties. A keyed property uses the original property name plus an additional dotted segment to represent a Map key, as my.property.key, where my.property is the property name and key is the Map key. All keyed properties are queried for their values, which represent a single entry in the returning Optional<Map> converting both the key and value using the specified Converters. The following configuration:

      • server.reasons.200=OK
      • server.reasons.201=CREATED
      • server.reasons.404=NOT_FOUND

      Results in a Optional<Map> with the entries 200=OK, 201=CREATED, and 404=NOT_FOUND, considering the configuration name as server.reasons and Converters to convert the key type as an Integer and the property type as a String.

      Otherwise, the configuration value is a single element represented by key value pairs as <key1>=<value1>;<key2>=<value2>... separated by a semicolon ; with the backslash (\) as the escape character. A configuration of server.reasons=200=OK;201=CREATED;404=NOT_FOUND results in a Optional<Map> with the entries 200=OK, 201=CREATED, and 404=NOT_FOUND, considering the configuration name as server.reasons and Converters to convert the key type as an Integer and the property type as a String.

      The keyed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      name - The configuration property name to look for in the configuration
      keyConverter - The Converter to use to convert the resolved property keys
      valueConverter - The Converter to use to convert the resolved property values
      mapFactory - the resulting instance of a Map to return the property keys and values
      Returns:
      the resolved property values as a Optional<Map> of keys of the property name and values of the property type
      Throws:
      IllegalArgumentException - if the property keys or values cannot be converted to the specified type
      NoSuchElementException - if the property isn't present in the configuration or is defined as an empty string, or the converter returns null
      See Also:
    • getOptionalValues

      public <K, V, C extends Collection<V>> Optional<Map<K,C>> getOptionalValues(String name, Class<K> keyClass, Class<V> valueClass, IntFunction<C> collectionFactory)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for keyed indexed properties. A keyed indexed property uses the original property name plus an additional dotted segment to represent a Map key followed by square brackets and an index in between, as my.property.key[0], where my.property is the property name, key is the Map key and {code [0]} the index of the Collection element. All keyed indexed properties are queried for their value, which represent a single entry in the returning Optional<Map>, and single element in the Collection value, converting both the key and value to their specified types. The following configuration:

      • server.env.prod[0]=alpha
      • server.env.prod[1]=beta
      • server.env.dev[0]=local

      Results in a Optional<Map> with the entry key prod and entry value Collection with the values alpha and beta, and the entry key dev and entry value Collection with the value local, considering the configuration name as server.env, the key type as a String, and the property type as a String.

      Otherwise, the configuration value is a single element represented by key value pairs as <key1>=<value1>;<key2>=<value2>... separated by a semicolon ; and value as a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration of server.env=prod=alpha,beta;dev=local results in a Optional<Map> with the entry key prod and entry value Collection with the values alpha and beta, and the entry key dev and entry value Collection with the value local, considering the configuration name as server.env, the key type as a String, and the property type as a String.

      The keyed indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      K - the key type
      V - the value type
      C - the collection type
      Parameters:
      name - The configuration property name to look for in the configuration
      keyClass - The type into which the resolved property keys are converted
      valueClass - The type into which the resolved property values are converted
      collectionFactory - the resulting instance of a Collection to return the property values
      Returns:
      the resolved property values as a Optional<Map> of keys of the property name and values as a Collections of instances of the property type
      Throws:
      IllegalArgumentException - if the property keys or values cannot be converted to the specified type
      See Also:
    • getOptionalValues

      public <K, V, C extends Collection<V>> Optional<Map<K,C>> getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter, IntFunction<Map<K,C>> mapFactory, IntFunction<C> collectionFactory)
      Returns the values for the specified configuration name from the underlying configuration sources.

      The lookup to the configuration will first query getPropertyNames() for keyed indexed properties. A keyed indexed property uses the original property name plus an additional dotted segment to represent a Map key followed by square brackets and an index in between, as my.property.key[0], where my.property is the property name, key is the Map key and {code [0]} the index of the Collection element. All keyed indexed properties are queried for their value, which represent a single entry in the returning Optional<Map>, and single element in the Collection value, converting both the key and value using the specified Converters. The following configuration:

      • server.env.prod[0]=alpha
      • server.env.prod[1]=beta
      • server.env.dev[0]=local

      Results in a Optional<Map> with the entry key prod and entry value Collection with the values alpha and beta, and the entry key dev and entry value Collection with the value local, considering the configuration name as server.env and Converters to convert the key type as a String and the property type as a String.

      Otherwise, the configuration value is a single element represented by key value pairs as <key1>=<value1>;<key2>=<value2>... separated by a semicolon ; and value as a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration of server.env=prod=alpha,beta;dev=local results in a Optional<Map> with the entry key prod and entry value Collection with the values alpha and beta, and the entry key dev and entry value Collection with the value local, considering the configuration name as server.env, and Converters to convert the key type as a String and the property type as a String.

      The keyed indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.

      Type Parameters:
      K - the key type
      V - the value type
      C - the collection type
      Parameters:
      name - The configuration property name to look for in the configuration
      keyConverter - The Converter to use to convert the resolved property keys
      valueConverter - The Converter to use to convert the resolved property values
      mapFactory - the resulting instance of a Map to return the property keys and values
      collectionFactory - the resulting instance of a Collection to return the property values
      Returns:
      the resolved property values as a Optional<Map> of keys of the property name and values as a Collections of instances of the property type
      Throws:
      IllegalArgumentException - if the property keys or values cannot be converted to the specified type
      See Also:
    • getConfigMapping

      public <T> T getConfigMapping(Class<T> type)
      Returns an instance of a ConfigMapping annotated type, mapping all the configuration names matching the ConfigMapping.prefix() and the ConfigMapping members to values from the underlying configuration sources.

      ConfigMapping instances are cached. They are populated when the SmallRyeConfig instance is initialized and their values are not updated on configuration sources changes.

      Type Parameters:
      T - the type of the ConfigMapping
      Parameters:
      type - an interface annotated with ConfigMapping
      Returns:
      an instance of a ConfigMapping annotated type
      Throws:
      ConfigValidationException - if the mapping names or values cannot be converter to the specified types, if the properties values are not present, defined as an empty string, or the conversion returns null
      See Also:
    • getConfigMapping

      public <T> T getConfigMapping(Class<T> type, String prefix)
      Returns an instance of a ConfigMapping annotated type, mapping all the configuration names matching the prefix and the ConfigMapping members to values from the underlying configuration sources.

      ConfigMapping instances are cached. They are populated when the SmallRyeConfig instance is initialized and their values are not updated on configuration sources changes.

      Type Parameters:
      T - the type of the ConfigMapping
      Parameters:
      type - an interface annotated with ConfigMapping
      prefix - the prefix to override ConfigMapping.prefix()
      Returns:
      an instance of a ConfigMapping annotated type
      Throws:
      ConfigValidationException - if the mapping names or values cannot be converter to the specified types, if the properties values are not present, defined as an empty string, or the conversion returns null
      See Also:
    • getPropertyNames

      public Iterable<String> getPropertyNames()
      This implementation caches the list of property names collected when SmallRyeConfig is built via SmallRyeConfigBuilder.build(). The cache may be disabled with SmallRyeConfigBuilder.isCachePropertyNames().
      Specified by:
      getPropertyNames in interface org.eclipse.microprofile.config.Config
      Returns:
      the cached names of all configured keys of the underlying configuration
      See Also:
    • getLatestPropertyNames

      public Iterable<String> getLatestPropertyNames()
      Provides a way to retrieve an updated list of all property names. The updated list replaces the cached list returned by getPropertyNames().
      Returns:
      the names of all configured keys of the underlying configuration
    • isPropertyPresent

      public boolean isPropertyPresent(String name)
      Checks if a property is present in the Config instance.
      Because ConfigSource.getPropertyNames() may not include all available properties, it is not possible to reliably determine if the property is present in the properties list. The property needs to be retrieved to make sure it exists. The lookup is done without expression expansion, because the expansion value may not be available, and it is not relevant for the final check.
      Parameters:
      name - the property name.
      Returns:
      true if the property is present or false otherwise.
    • getConfigSources

      public Iterable<org.eclipse.microprofile.config.spi.ConfigSource> getConfigSources()
      Specified by:
      getConfigSources in interface org.eclipse.microprofile.config.Config
    • getConfigSources

      public Iterable<org.eclipse.microprofile.config.spi.ConfigSource> getConfigSources(Class<?> type)
      Return the currently registered configuration sources in SmallRyeConfig that match the specified type

      The returned sources will be sorted by descending ordinal value and name, which can be iterated in a thread-safe manner. The Iterable contains a fixed number of configuration sources, determined at configuration initialization, and the config sources themselves may be static or dynamic.

      Parameters:
      type - The type of the ConfigSource to look for in the configuration
      Returns:
      an Iterable of configuration sources
    • getConfigSource

      public Optional<org.eclipse.microprofile.config.spi.ConfigSource> getConfigSource(String name)
      Return the first registered configuration sources in SmallRyeConfig that match the specified name, sorted by descending ordinal value and name.

      Parameters:
      name - the {ConfigSource name to look for in the configuration
      Returns:
      an Optional of a ConfigSource, or an empty Optional if no ConfigSource matches the specified name.
    • convert

      @Deprecated public <T> T convert(String value, Class<T> asType)
      Deprecated.
    • getConverter$$bridge

      @Deprecated public <T> org.eclipse.microprofile.config.spi.Converter<T> getConverter$$bridge(Class<T> asType)
      Deprecated.
    • getConverter

      public <T> Optional<org.eclipse.microprofile.config.spi.Converter<T>> getConverter(Class<T> asType)
      Specified by:
      getConverter in interface org.eclipse.microprofile.config.Config
    • requireConverter

      public <T> org.eclipse.microprofile.config.spi.Converter<T> requireConverter(Class<T> asType)
      Return the Converter used by this instance to produce instances of the specified type from String values.
      Type Parameters:
      T - the conversion type
      Parameters:
      asType - the type to be produced by the converter
      Returns:
      an instance of the Converter the specified type
      Throws:
      IllegalArgumentException - if no Converter is registered for the specified type
    • unwrap

      public <T> T unwrap(Class<T> type)
      Specified by:
      unwrap in interface org.eclipse.microprofile.config.Config
    • getProfiles

      public List<String> getProfiles()
      Returns a List of the active profiles in SmallRyeConfig.

      Profiles are sorted in reverse order according to how they were set in SMALLRYE_CONFIG_PROFILE, as the last profile overrides the previous one until there are no profiles left in the list.

      Returns:
      a List of the active profiles