Package io.smallrye.config
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
- Author:
- Jeff Mesnil (c) 2017 Red Hat inc.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from interface org.eclipse.microprofile.config.Config
PROFILE, PROPERTY_EXPRESSIONS_ENABLED -
Method Summary
Modifier and TypeMethodDescription<T> T<T> TconvertValue(ConfigValue configValue, org.eclipse.microprofile.config.spi.Converter<T> converter) This method handles converting values for both CDI injections and programatical calls.
Calls for converting non-optional values (Config.getValue(java.lang.String, java.lang.Class<T>)and "Injecting Native Values") should throw anExceptionfor each of the following:
1.<T> TgetConfigMapping(Class<T> type) <T> TgetConfigMapping(Class<T> type, String prefix) Optional<org.eclipse.microprofile.config.spi.ConfigSource> getConfigSource(String name) Iterable<org.eclipse.microprofile.config.spi.ConfigSource> Iterable<org.eclipse.microprofile.config.spi.ConfigSource> getConfigSources(Class<?> type) getConfigValue(String name) <T> Optional<org.eclipse.microprofile.config.spi.Converter<T>> getConverter(Class<T> asType) <T> org.eclipse.microprofile.config.spi.Converter<T> getConverter$$bridge(Class<T> asType) Deprecated.<T,C extends Collection<T>>
Optional<C> getIndexedOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory) getIndexedProperties(String property) getIndexedPropertiesIndexes(String property) <T,C extends Collection<T>>
CgetIndexedValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory) Provides a way to retrieve an updated list of all property names.getMapIndexedKeys(String name) getMapKeys(String name) <T> Optional<T> getOptionalValue(String name, Class<T> aClass) <T> Optional<T> getOptionalValue(String name, org.eclipse.microprofile.config.spi.Converter<T> converter) getOptionalValues(String name, Class<K> keyClass, Class<V> valueClass) Return the content of the direct sub properties as the requested type of Map.<K,V, C extends Collection<V>>
Optional<Map<K, C>> getOptionalValues(String name, Class<K> keyClass, Class<V> valueClass, IntFunction<C> collectionFactory) getOptionalValues(String propertyName, Class<T> propertyType) <T,C extends Collection<T>>
Optional<C> getOptionalValues(String name, Class<T> itemClass, IntFunction<C> collectionFactory) getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter) <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) getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter, IntFunction<Map<K, V>> mapFactory) <T,C extends Collection<T>>
Optional<C> getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory) This implementation caches the list of property names collected whenSmallRyeConfigis built viaSmallRyeConfigBuilder.build().getRawValue(String name) Get the raw value of a configuration property.<T> T<T> TThis method handles calls from bothConfig.getValue(java.lang.String, java.lang.Class<T>)andConfig.getOptionalValue(java.lang.String, java.lang.Class<T>).<K,V> Map <K, V> Return the content of the direct sub properties as the requested type of Map.<K,V, C extends Collection<V>>
Map<K, C> getValues(String name, Class<K> keyClass, Class<V> valueClass, IntFunction<C> collectionFactory) <T> List<T> <T,C extends Collection<T>>
CgetValues(String name, Class<T> itemClass, IntFunction<C> collectionFactory) <K,V> Map <K, V> getValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter) <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) <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) Return the content of the direct sub properties as the requested type of Map.<T,C extends Collection<T>>
CgetValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory) booleanisPropertyPresent(String name) Checks if a property is present in theConfiginstance.<T> org.eclipse.microprofile.config.spi.Converter<T> requireConverter(Class<T> asType) <T> T
-
Field Details
-
SMALLRYE_CONFIG_PROFILE
- See Also:
-
SMALLRYE_CONFIG_PROFILE_PARENT
- See Also:
-
SMALLRYE_CONFIG_LOCATIONS
- See Also:
-
SMALLRYE_CONFIG_MAPPING_VALIDATE_UNKNOWN
- See Also:
-
SMALLRYE_CONFIG_SECRET_HANDLERS
- See Also:
-
SMALLRYE_CONFIG_LOG_VALUES
- See Also:
-
-
Method Details
-
getValues
- Specified by:
getValuesin interfaceorg.eclipse.microprofile.config.Config
-
getValues
public <T,C extends Collection<T>> C getValues(String name, Class<T> itemClass, IntFunction<C> collectionFactory) -
getValues
public <T,C extends Collection<T>> C getValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory) -
getIndexedValues
public <T,C extends Collection<T>> C getIndexedValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory) -
getIndexedProperties
-
getIndexedPropertiesIndexes
-
getValues
Return the content of the direct sub properties as the requested type of Map.- Type Parameters:
K- the key typeV- the value type- Parameters:
name- The configuration property namekeyClass- the type into which the keys should be convertedvalueClass- the type into which the values should be converted- Returns:
- the resolved property value as an instance of the requested Map (not
null) - Throws:
IllegalArgumentException- if a key or a value cannot be converted to the specified typesNoSuchElementException- if no direct sub properties could be found.
-
getValues
-
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) Return the content of the direct sub properties as the requested type of Map.- Type Parameters:
K- The type of the keys.V- The type of the values.- Parameters:
name- The configuration property namekeyConverter- The converter to use for the keys.valueConverter- The converter to use for the values.- Returns:
- the resolved property value as an instance of the requested Map or
nullif it could not be found. - Throws:
IllegalArgumentException- if a key or a value cannot be converted to the specified typesNoSuchElementException- if no direct sub properties could be found.
-
getValues
public <K,V, Map<K,C extends Collection<V>> C> getValues(String name, Class<K> keyClass, Class<V> valueClass, IntFunction<C> collectionFactory) -
getValues
public <K,V, Map<K,C extends Collection<V>> 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) -
getMapKeys
-
getMapIndexedKeys
-
getValue
- Specified by:
getValuein interfaceorg.eclipse.microprofile.config.Config
-
getValue
This method handles calls from bothConfig.getValue(java.lang.String, java.lang.Class<T>)andConfig.getOptionalValue(java.lang.String, java.lang.Class<T>). -
convertValue
public <T> T convertValue(ConfigValue configValue, org.eclipse.microprofile.config.spi.Converter<T> converter) This method handles converting values for both CDI injections and programatical calls.
Calls for converting non-optional values (Config.getValue(java.lang.String, java.lang.Class<T>)and "Injecting Native Values") should throw anExceptionfor each of the following:
1.IllegalArgumentException- if the property cannot be converted by theConverterto the specified type
2.NoSuchElementException- if the property is not defined
3.NoSuchElementException- if the property is defined as an empty string
4.NoSuchElementException- if theConverterreturnsnull
Calls for converting optional values (Config.getOptionalValue(java.lang.String, java.lang.Class<T>)and "Injecting Optional Values") should only throw anExceptionfor #1 (IllegalArgumentExceptionwhen the property cannot be converted to the specified type). -
getConfigValue
- Specified by:
getConfigValuein interfaceorg.eclipse.microprofile.config.Config
-
getRawValue
Get the raw value of a configuration property.- Parameters:
name- the property name (must not benull)- Returns:
- the raw value, or
nullif no property value was discovered for the given property name
-
getOptionalValue
- Specified by:
getOptionalValuein interfaceorg.eclipse.microprofile.config.Config
-
getOptionalValue
-
getOptionalValues
- Specified by:
getOptionalValuesin interfaceorg.eclipse.microprofile.config.Config
-
getOptionalValues
public <T,C extends Collection<T>> Optional<C> getOptionalValues(String name, Class<T> itemClass, IntFunction<C> collectionFactory) -
getOptionalValues
public <T,C extends Collection<T>> Optional<C> getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory) -
getIndexedOptionalValues
public <T,C extends Collection<T>> Optional<C> getIndexedOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory) -
getOptionalValues
public <K,V> Optional<Map<K,V>> getOptionalValues(String name, Class<K> keyClass, Class<V> valueClass) Return the content of the direct sub properties as the requested type of Map.- Type Parameters:
K- the key typeV- the value type- Parameters:
name- The configuration property namekeyClass- the type into which the keys should be convertedvalueClass- the type into which the values should be converted- Returns:
- the resolved property value as an instance of the requested Map (not
null) - Throws:
IllegalArgumentException- if a key or a value cannot be converted to the specified types
-
getOptionalValues
-
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) -
getOptionalValues
public <K,V, Optional<Map<K,C extends Collection<V>> C>> getOptionalValues(String name, Class<K> keyClass, Class<V> valueClass, IntFunction<C> collectionFactory) -
getOptionalValues
public <K,V, Optional<Map<K,C extends Collection<V>> 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) -
getConfigMapping
-
getConfigMapping
-
getPropertyNames
This implementation caches the list of property names collected whenSmallRyeConfigis built viaSmallRyeConfigBuilder.build().- Specified by:
getPropertyNamesin interfaceorg.eclipse.microprofile.config.Config- Returns:
- the cached names of all configured keys of the underlying configuration
- See Also:
-
getLatestPropertyNames
@Experimental("Retrieve an updated list of all configuration property names") public Iterable<String> getLatestPropertyNames()Provides a way to retrieve an updated list of all property names. The updated list replaces the cached list returned bygetPropertyNames().- Returns:
- the names of all configured keys of the underlying configuration
-
isPropertyPresent
Checks if a property is present in theConfiginstance.
BecauseConfigSource.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
- Specified by:
getConfigSourcesin interfaceorg.eclipse.microprofile.config.Config
-
getConfigSources
-
getConfigSource
-
convert
-
getConverter$$bridge
@Deprecated public <T> org.eclipse.microprofile.config.spi.Converter<T> getConverter$$bridge(Class<T> asType) Deprecated. -
getConverter
- Specified by:
getConverterin interfaceorg.eclipse.microprofile.config.Config
-
requireConverter
-
unwrap
- Specified by:
unwrapin interfaceorg.eclipse.microprofile.config.Config
-
getProfiles
-