Class ConfigUtils

java.lang.Object
io.quarkus.runtime.configuration.ConfigUtils

public final class ConfigUtils extends Object
  • Method Details

    • configBuilder

      public static io.smallrye.config.SmallRyeConfigBuilder configBuilder()
    • emptyConfigBuilder

      public static io.smallrye.config.SmallRyeConfigBuilder emptyConfigBuilder()
    • getProfiles

      public static List<String> getProfiles()
      Returns a List of 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 List of the active profiles
      See Also:
      • SmallRyeConfig.getProfiles()
    • isProfileActive

      public static boolean isProfileActive(String profile)
      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

      public static boolean isPropertyPresent(String propertyName)
      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

      public static boolean isPropertyNonEmpty(String propertyName)
      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

      public static boolean isAnyPropertyPresent(Collection<String> propertyNames)
      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, or Optional.empty() if none of the properties is present.
      Type Parameters:
      T - The property type
      Parameters:
      propertyNames - The configuration property names
      propertyType - The type that the resolved property value should be converted to
      Returns:
      true if the property is present or false otherwise.