public final class ConfigUtils extends Object
Modifier and Type | Method and Description |
---|---|
static Set<String> |
collectKeys(Map<String,Object> map) |
static <T> T |
getConfigValue(Map<String,Object> config,
String key)
Returns the value for the specified key with an optional default value if no match is found.
|
static <T> T |
getConfigValue(Map<String,Object> config,
String key,
T defaultValue)
Returns the value for the specified key with an optional default value if no match is found.
|
static <T> T |
getConfigValue(ResourceBundle config,
String key)
Returns the value for the specified key with an optional default value if no match is found.
|
static <T> T |
getConfigValue(ResourceBundle config,
String key,
T defaultValue)
Returns the value for the specified key with an optional default value if no match is found.
|
static boolean |
getConfigValueAsBoolean(Map<String,Object> config,
String key)
Returns the value for the specified key coerced to a boolean.
|
static boolean |
getConfigValueAsBoolean(Map<String,Object> config,
String key,
boolean defaultValue)
Returns the value for the specified key with an optional default value if no match is found.
|
static double |
getConfigValueAsDouble(Map<String,Object> config,
String key)
Returns the value for the specified key coerced to a double.
|
static double |
getConfigValueAsDouble(Map<String,Object> config,
String key,
double defaultValue)
Returns the value for the specified key with an optional default value if no match is found.
|
static float |
getConfigValueAsFloat(Map<String,Object> config,
String key)
Returns the value for the specified key coerced to a float.
|
static float |
getConfigValueAsFloat(Map<String,Object> config,
String key,
float defaultValue)
Returns the value for the specified key with an optional default value if no match is found.
|
static int |
getConfigValueAsInt(Map<String,Object> config,
String key)
Returns the value for the specified key coerced to an int.
|
static int |
getConfigValueAsInt(Map<String,Object> config,
String key,
int defaultValue)
Returns the value for the specified key with an optional default value if no match is found.
|
static long |
getConfigValueAsLong(Map<String,Object> config,
String key)
Returns the value for the specified key coerced to a long.
|
static long |
getConfigValueAsLong(Map<String,Object> config,
String key,
long defaultValue)
Returns the value for the specified key with an optional default value if no match is found.
|
static Number |
getConfigValueAsNumber(Map<String,Object> config,
String key)
Returns the value for the specified key coerced to a Number.
|
static Number |
getConfigValueAsNumber(Map<String,Object> config,
String key,
Number defaultValue)
Returns the value for the specified key with an optional default value if no match is found.
|
static String |
getConfigValueAsString(Map<String,Object> config,
String key)
Returns the value for the specified key converted to a String.
|
static String |
getConfigValueAsString(Map<String,Object> config,
String key,
String defaultValue)
Returns the value for the specified key with an optional default value if no match is found.
|
static String |
getFilenameExtension(String path)
Extract the filename extension from the given path,
e.g.
|
static boolean |
isValueDefined(Map<String,Object> config,
String key)
Returns true if there's a on-null value for the specified key.
|
static boolean |
isValueDefined(ResourceBundle config,
String key)
Returns true if there's a on-null value for the specified key.
|
static String |
stripFilenameExtension(String path)
Strip the filename extension from the given path,
e.g.
|
public static boolean isValueDefined(@Nonnull Map<String,Object> config, @Nonnull String key)
config
- the configuration object to be searched uponkey
- the key to be searchedpublic static boolean isValueDefined(@Nonnull ResourceBundle config, @Nonnull String key)
config
- the configuration object to be searched uponkey
- the key to be searched@Nullable public static <T> T getConfigValue(@Nonnull Map<String,Object> config, @Nonnull String key, @Nullable T defaultValue)
config
- the configuration object to be searched uponkey
- the key to be searcheddefaultValue
- the value to send back if no match is found@Nullable public static <T> T getConfigValue(@Nonnull ResourceBundle config, @Nonnull String key, @Nullable T defaultValue)
config
- the configuration object to be searched uponkey
- the key to be searcheddefaultValue
- the value to send back if no match is found@Nullable public static <T> T getConfigValue(@Nonnull Map<String,Object> config, @Nonnull String key) throws MissingResourceException
config
- the configuration object to be searched uponkey
- the key to be searchedMissingResourceException
@Nullable public static <T> T getConfigValue(@Nonnull ResourceBundle config, @Nonnull String key) throws MissingResourceException
config
- the configuration object to be searched uponkey
- the key to be searchedMissingResourceException
public static boolean getConfigValueAsBoolean(@Nonnull Map<String,Object> config, @Nonnull String key)
config
- the configuration object to be searched uponkey
- the key to be searchedfalse
if no match.public static boolean getConfigValueAsBoolean(@Nonnull Map<String,Object> config, @Nonnull String key, boolean defaultValue)
config
- the configuration object to be searched uponkey
- the key to be searcheddefaultValue
- the value to send back if no match is foundpublic static int getConfigValueAsInt(@Nonnull Map<String,Object> config, @Nonnull String key)
config
- the configuration object to be searched uponkey
- the key to be searched0
if no match.public static int getConfigValueAsInt(@Nonnull Map<String,Object> config, @Nonnull String key, int defaultValue)
config
- the configuration object to be searched uponkey
- the key to be searcheddefaultValue
- the value to send back if no match is foundpublic static long getConfigValueAsLong(@Nonnull Map<String,Object> config, @Nonnull String key)
config
- the configuration object to be searched uponkey
- the key to be searched0L
if no match.public static long getConfigValueAsLong(@Nonnull Map<String,Object> config, @Nonnull String key, long defaultValue)
config
- the configuration object to be searched uponkey
- the key to be searcheddefaultValue
- the value to send back if no match is foundpublic static double getConfigValueAsDouble(@Nonnull Map<String,Object> config, @Nonnull String key)
config
- the configuration object to be searched uponkey
- the key to be searched0d
if no match.public static double getConfigValueAsDouble(@Nonnull Map<String,Object> config, @Nonnull String key, double defaultValue)
config
- the configuration object to be searched uponkey
- the key to be searcheddefaultValue
- the value to send back if no match is foundpublic static float getConfigValueAsFloat(@Nonnull Map<String,Object> config, @Nonnull String key)
config
- the configuration object to be searched uponkey
- the key to be searched0f
if no match.public static float getConfigValueAsFloat(@Nonnull Map<String,Object> config, @Nonnull String key, float defaultValue)
config
- the configuration object to be searched uponkey
- the key to be searcheddefaultValue
- the value to send back if no match is found@Nullable public static Number getConfigValueAsNumber(@Nonnull Map<String,Object> config, @Nonnull String key)
config
- the configuration object to be searched uponkey
- the key to be searchednull
if no match.@Nullable public static Number getConfigValueAsNumber(@Nonnull Map<String,Object> config, @Nonnull String key, @Nullable Number defaultValue)
config
- the configuration object to be searched uponkey
- the key to be searcheddefaultValue
- the value to send back if no match is found@Nullable public static String getConfigValueAsString(@Nonnull Map<String,Object> config, @Nonnull String key)
config
- the configuration object to be searched uponkey
- the key to be searched""
if no match.@Nullable public static String getConfigValueAsString(@Nonnull Map<String,Object> config, @Nonnull String key, @Nullable String defaultValue)
config
- the configuration object to be searched uponkey
- the key to be searcheddefaultValue
- the value to send back if no match is foundpublic static String getFilenameExtension(String path)
path
- the file path (may be null
)null
if nonepublic static String stripFilenameExtension(String path)
path
- the file path (may be null
)null
if none