Package dev.voidframework.core.utils
Class ConfigurationUtils
java.lang.Object
dev.voidframework.core.utils.ConfigurationUtils
Utility methods to use with application configuration.
- Since:
- 1.9.0
-
Method Summary
Modifier and TypeMethodDescriptiongetAllRootLevelPaths(com.typesafe.config.Config configuration, String path) Gets all root paths for the given path expression.static booleangetBooleanOrDefault(com.typesafe.config.Config configuration, String path, boolean defaultValue) Gets the boolean at the given path.static booleangetBooleanOrFallback(com.typesafe.config.Config configuration, String path, String fallbackPath) Gets the boolean at the given path.static longgetBytesOrDefault(com.typesafe.config.Config configuration, String path, long defaultValue) Gets a value as a size in bytes (parses special strings like "128M").static longgetBytesOrFallback(com.typesafe.config.Config configuration, String path, String fallbackPath) Gets a value as a size in bytes (parses special strings like "128M").static DurationgetDurationOrDefault(com.typesafe.config.Config configuration, String path, Duration defaultValue) Gets a value as a Duration.static longgetDurationOrDefault(com.typesafe.config.Config configuration, String path, TimeUnit unit, long defaultValue) Gets a value as a Duration.static DurationgetDurationOrFallback(com.typesafe.config.Config configuration, String path, String fallbackPath) Gets a value as a Duration.static longgetDurationOrFallback(com.typesafe.config.Config configuration, String path, TimeUnit unit, String fallbackPath) Gets a value as a Duration.static <T extends Enum<T>>
TgetEnumOrDefault(com.typesafe.config.Config configuration, String path, Class<T> enumClassType, T defaultValue) Gets a value as an Enum.static <T extends Enum<T>>
TgetEnumOrFallback(com.typesafe.config.Config configuration, String path, Class<T> enumClassType, String fallbackPath) Gets a value as a Enum.static intgetIntOrDefault(com.typesafe.config.Config configuration, String path, int defaultValue) Gets the integer at the given path.static intgetIntOrFallback(com.typesafe.config.Config configuration, String path, String fallbackPath) Gets the integer at the given path.static longgetLongOrDefault(com.typesafe.config.Config configuration, String path, long defaultValue) Gets the long at the given path.static longgetLongOrFallback(com.typesafe.config.Config configuration, String path, String fallbackPath) Gets the long at the given path.static StringgetStringOrDefault(com.typesafe.config.Config configuration, String path, String defaultValue) Gets the string at the given path.static StringgetStringOrFallback(com.typesafe.config.Config configuration, String path, String fallbackPath) Gets the string at the given path.static TemporalAmountgetTemporalOrDefault(com.typesafe.config.Config configuration, String path, TemporalAmount defaultValue) Gets a value as a TemporalAmount.static TemporalAmountgetTemporalOrFallback(com.typesafe.config.Config configuration, String path, String fallbackPath) Gets a value as a TemporalAmount.static booleanhasAnyPath(com.typesafe.config.Config configuration, String... pathArray) Checks whether a value is present and non-null for at least one of the given paths.
-
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 configurationpath- 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 configurationpath- Path expressiondefaultValue- 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 configurationpath- Path expressionfallbackPath- 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 configurationpath- Path expressiondefaultValue- 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 configurationpath- Path expressionfallbackPath- 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 configurationpath- Path expressiondefaultValue- 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 configurationpath- Path expressionfallbackPath- 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 configurationpath- Path expressionunit- Convert the return value to this time unitdefaultValue- 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 configurationpath- Path expressionunit- Convert the return value to this time unitfallbackPath- 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 configurationpath- Path expressionenumClassType- An enum classdefaultValue- 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 configurationpath- Path expressionenumClassType- An enum classfallbackPath- 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 configurationpath- Path expressiondefaultValue- 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 configurationpath- Path expressionfallbackPath- 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 configurationpath- Path expressiondefaultValue- 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 configurationpath- Path expressionfallbackPath- 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 configurationpath- Path expressiondefaultValue- 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 configurationpath- Path expressionfallbackPath- 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 configurationpath- Path expressiondefaultValue- 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 configurationpath- Path expressionfallbackPath- Path expression to use as fallback- Returns:
- The TemporalAmount value at the requested path
- Since:
- 1.9.0
-
hasAnyPath
Checks whether a value is present and non-null for at least one of the given paths.- Returns:
trueif value is present and non-null for at least one of the given paths, otherwisefalse- Since:
- 1.10.0
-