Class ConfigUtils

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

public final class ConfigUtils extends Object
  • Field Details

    • UUID_KEY

      static final String UUID_KEY
      The name of the property associated with a random UUID generated at launch time.
      See Also:
  • Method Details

    • listFactory

      public static <T> IntFunction<List<T>> listFactory()
    • setFactory

      public static <T> IntFunction<Set<T>> setFactory()
    • sortedSetFactory

      public static <T> IntFunction<SortedSet<T>> sortedSetFactory()
    • configBuilder

      public static io.smallrye.config.SmallRyeConfigBuilder configBuilder(boolean runTime, LaunchMode launchMode)
    • configBuilder

      public static io.smallrye.config.SmallRyeConfigBuilder configBuilder(boolean runTime, boolean addDiscovered, LaunchMode launchMode)
      Get the basic configuration builder.
      Parameters:
      runTime - true if the configuration is run time, false if build time
      addDiscovered - true if the ConfigSource and Converter objects should be auto-discovered
      Returns:
      the configuration builder
    • emptyConfigBuilder

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

      public static List<String> getProfiles()
    • isProfileActive

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