Class ConfigurationUtils

java.lang.Object
dev.voidframework.core.utils.ConfigurationUtils

public final class ConfigurationUtils extends Object
Utility methods to use with application configuration.
Since:
1.9.0
  • Method Details

    • getAllRootLevelPaths

      public static Set<String> getAllRootLevelPaths(com.typesafe.config.Config configuration, String path)
      Gets all root paths for the given path expression.
      Parameters:
      configuration - The application configuration
      path - Path expression
      Returns:
      All base paths
      Since:
      1.9.0
    • getBooleanOrDefault

      public static boolean getBooleanOrDefault(com.typesafe.config.Config configuration, String path, boolean defaultValue)
      Gets the boolean at the given path.
      Parameters:
      configuration - The application configuration
      path - Path expression
      defaultValue - The default value returned if path does not exist or value is null
      Returns:
      The boolean value at the requested path
      Since:
      1.9.0
    • getBooleanOrFallback

      public static boolean getBooleanOrFallback(com.typesafe.config.Config configuration, String path, String fallbackPath)
      Gets the boolean at the given path.
      Parameters:
      configuration - The application configuration
      path - Path expression
      fallbackPath - Path expression to use as fallback
      Returns:
      The boolean value at the requested path
      Since:
      1.9.0
    • getBytesOrDefault

      public static long getBytesOrDefault(com.typesafe.config.Config configuration, String path, long defaultValue)
      Gets a value as a size in bytes (parses special strings like "128M").
      Parameters:
      configuration - The application configuration
      path - Path expression
      defaultValue - The default value returned if path does not exist or value is null
      Returns:
      The value at the requested path, in bytes
      Since:
      1.9.0
    • getBytesOrFallback

      public static long getBytesOrFallback(com.typesafe.config.Config configuration, String path, String fallbackPath)
      Gets a value as a size in bytes (parses special strings like "128M").
      Parameters:
      configuration - The application configuration
      path - Path expression
      fallbackPath - Path expression to use as fallback
      Returns:
      The value at the requested path, in bytes
      Since:
      1.9.0
    • getDurationOrDefault

      public static Duration getDurationOrDefault(com.typesafe.config.Config configuration, String path, Duration defaultValue)
      Gets a value as a Duration.
      Parameters:
      configuration - The application configuration
      path - Path expression
      defaultValue - The default value returned if path does not exist or value is null
      Returns:
      The duration value at the requested path
      Since:
      1.9.0
    • getDurationOrFallback

      public static Duration getDurationOrFallback(com.typesafe.config.Config configuration, String path, String fallbackPath)
      Gets a value as a Duration.
      Parameters:
      configuration - The application configuration
      path - Path expression
      fallbackPath - Path expression to use as fallback
      Returns:
      The duration value at the requested path
      Since:
      1.9.0
    • getDurationOrDefault

      public static long getDurationOrDefault(com.typesafe.config.Config configuration, String path, TimeUnit unit, long defaultValue)
      Gets a value as a Duration.
      Parameters:
      configuration - The application configuration
      path - Path expression
      unit - Convert the return value to this time unit
      defaultValue - The default value returned if path does not exist or value is null
      Returns:
      The Duration value at the requested path
      Since:
      1.9.0
    • getDurationOrFallback

      public static long getDurationOrFallback(com.typesafe.config.Config configuration, String path, TimeUnit unit, String fallbackPath)
      Gets a value as a Duration.
      Parameters:
      configuration - The application configuration
      path - Path expression
      unit - Convert the return value to this time unit
      fallbackPath - Path expression to use as fallback
      Returns:
      The Duration value at the requested path
      Since:
      1.9.0
    • getEnumOrDefault

      public static <T extends Enum<T>> T getEnumOrDefault(com.typesafe.config.Config configuration, String path, Class<T> enumClassType, T defaultValue)
      Gets a value as an Enum.
      Parameters:
      configuration - The application configuration
      path - Path expression
      enumClassType - An enum class
      defaultValue - The default value returned if path does not exist or value is null
      Returns:
      The Enum value at the requested path
      Since:
      1.9.0
    • getEnumOrFallback

      public static <T extends Enum<T>> T getEnumOrFallback(com.typesafe.config.Config configuration, String path, Class<T> enumClassType, String fallbackPath)
      Gets a value as a Enum.
      Parameters:
      configuration - The application configuration
      path - Path expression
      enumClassType - An enum class
      fallbackPath - Path expression to use as fallback
      Returns:
      The Enum value at the requested path
      Since:
      1.9.0
    • getIntOrDefault

      public static int getIntOrDefault(com.typesafe.config.Config configuration, String path, int defaultValue)
      Gets the integer at the given path.
      Parameters:
      configuration - The application configuration
      path - Path expression
      defaultValue - The default value returned if path does not exist or value is null
      Returns:
      The integer value at the requested path
      Since:
      1.9.0
    • getIntOrFallback

      public static int getIntOrFallback(com.typesafe.config.Config configuration, String path, String fallbackPath)
      Gets the integer at the given path.
      Parameters:
      configuration - The application configuration
      path - Path expression
      fallbackPath - Path expression to use as fallback
      Returns:
      The integer value at the requested path
      Since:
      1.9.0
    • getLongOrDefault

      public static long getLongOrDefault(com.typesafe.config.Config configuration, String path, long defaultValue)
      Gets the long at the given path.
      Parameters:
      configuration - The application configuration
      path - Path expression
      defaultValue - The default value returned if path does not exist or value is null
      Returns:
      The long value at the requested path
      Since:
      1.9.0
    • getLongOrFallback

      public static long getLongOrFallback(com.typesafe.config.Config configuration, String path, String fallbackPath)
      Gets the long at the given path.
      Parameters:
      configuration - The application configuration
      path - Path expression
      fallbackPath - Path expression to use as fallback
      Returns:
      The long value at the requested path
      Since:
      1.9.0
    • getStringOrDefault

      public static String getStringOrDefault(com.typesafe.config.Config configuration, String path, String defaultValue)
      Gets the string at the given path.
      Parameters:
      configuration - The application configuration
      path - Path expression
      defaultValue - The default value returned if path does not exist or value is null
      Returns:
      The string value at the requested path
      Since:
      1.9.0
    • getStringOrFallback

      public static String getStringOrFallback(com.typesafe.config.Config configuration, String path, String fallbackPath)
      Gets the string at the given path.
      Parameters:
      configuration - The application configuration
      path - Path expression
      fallbackPath - Path expression to use as fallback
      Returns:
      The string value at the requested path
      Since:
      1.9.0
    • getTemporalOrDefault

      public static TemporalAmount getTemporalOrDefault(com.typesafe.config.Config configuration, String path, TemporalAmount defaultValue)
      Gets a value as a TemporalAmount.
      Parameters:
      configuration - The application configuration
      path - Path expression
      defaultValue - The default value returned if path does not exist or value is null
      Returns:
      The TemporalAmount value at the requested path
      Since:
      1.9.0
    • getTemporalOrFallback

      public static TemporalAmount getTemporalOrFallback(com.typesafe.config.Config configuration, String path, String fallbackPath)
      Gets a value as a TemporalAmount.
      Parameters:
      configuration - The application configuration
      path - Path expression
      fallbackPath - Path expression to use as fallback
      Returns:
      The TemporalAmount value at the requested path
      Since:
      1.9.0
    • hasAnyPath

      public static boolean hasAnyPath(com.typesafe.config.Config configuration, String... pathArray)
      Checks whether a value is present and non-null for at least one of the given paths.
      Returns:
      true if value is present and non-null for at least one of the given paths, otherwise false
      Since:
      1.10.0