Class ConfigUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic io.smallrye.config.SmallRyeConfigBuilderstatic io.smallrye.config.SmallRyeConfigBuilderstatic <T> Optional<T> getFirstOptionalValue(List<String> propertyNames, Class<T> propertyType) Get the value of the first given property present in the current Configuration, orOptional.empty()if none of the properties is present.Returns aListof the active profiles in Quarkus.static booleanisAnyPropertyPresent(Collection<String> propertyNames) Checks if any of the given properties is present in the current Configuration.static booleanisProfileActive(String profile) Check if a configuration profile is active in Quarkus.static booleanisPropertyNonEmpty(String propertyName) Checks if a property has non-empty value in the current Configuration.static booleanisPropertyPresent(String propertyName) Checks if a property is present in the current Configuration.
-
Method Details
-
configBuilder
public static io.smallrye.config.SmallRyeConfigBuilder configBuilder() -
emptyConfigBuilder
public static io.smallrye.config.SmallRyeConfigBuilder emptyConfigBuilder() -
getProfiles
Returns aListof the active profiles in Quarkus.Profiles are sorted in reverse order according to how they were set in
quarkus.profile, as the last profile overrides the previous one until there are no profiles left in the list.- Returns:
- a
Listof the active profiles - See Also:
-
isProfileActive
Check if a configuration profile is active in Quarkus.- Parameters:
profile- the configuration profile to check- Returns:
- true if the profile is active or false otherwise.
-
isPropertyPresent
Checks if a property is present in the current Configuration.Because the sources may not expose the property directly in
ConfigSource.getPropertyNames(), we cannot reliably determine if the property is present in the properties list. The property needs to be retrieved to make sure it exists. Also, if the value is an expression, we want to ignore expansion, because this is not relevant for the check and the expansion value may not be available at this point.It may be interesting to expose such API in SmallRyeConfig directly.
- Parameters:
propertyName- the property name.- Returns:
- true if the property is present or false otherwise.
-
isPropertyNonEmpty
Checks if a property has non-empty value in the current Configuration.This method is similar to
isPropertyPresent(String), but does not ignore expression expansion.- Parameters:
propertyName- the property name.- Returns:
- true if the property is present or false otherwise.
-
isAnyPropertyPresent
Checks if any of the given properties is present in the current Configuration.Because the sources may not expose the property directly in
ConfigSource.getPropertyNames(), we cannot reliably determine if the property is present in the properties list. The property needs to be retrieved to make sure it exists. Also, if the value is an expression, we want to ignore expansion, because this is not relevant for the check and the expansion value may not be available at this point.It may be interesting to expose such API in SmallRyeConfig directly.
- Parameters:
propertyNames- The configuration property names- Returns:
- true if the property is present or false otherwise.
-
getFirstOptionalValue
public static <T> Optional<T> getFirstOptionalValue(List<String> propertyNames, Class<T> propertyType) Get the value of the first given property present in the current Configuration, orOptional.empty()if none of the properties is present.- Type Parameters:
T- The property type- Parameters:
propertyNames- The configuration property namespropertyType- The type that the resolved property value should be converted to- Returns:
- true if the property is present or false otherwise.
-