public final class ConfigUtils extends Object
Config instances.| Modifier and Type | Method and Description |
|---|---|
static com.typesafe.config.Config |
deserialize(String serialized) |
static com.typesafe.config.Config |
getDefault()
Returns the default
Config object for this app, based on config in the JAR file
or otherwise specified to the library. |
static Double |
getOptionalDouble(com.typesafe.config.Config config,
String key) |
static String |
getOptionalString(com.typesafe.config.Config config,
String key) |
static List<String> |
getOptionalStringList(com.typesafe.config.Config config,
String key) |
static Properties |
keyValueToProperties(Object... keyValues) |
static com.typesafe.config.Config |
overlayOn(Map<String,?> overlay,
com.typesafe.config.Config underlying) |
static String |
prettyPrint(com.typesafe.config.Config config) |
static String |
serialize(com.typesafe.config.Config config) |
static void |
set(Map<String,Object> overlay,
String key,
Path path)
Helper to set a
Path value correctly for use with overlayOn(Map,Config). |
public static com.typesafe.config.Config getDefault()
Config object for this app, based on config in the JAR file
or otherwise specified to the library.public static com.typesafe.config.Config overlayOn(Map<String,?> overlay, com.typesafe.config.Config underlying)
overlay - map of key-value pairs to add to default config. The map is converted
to a string representation, as it were from a config file, and parsed accordingly.underlying - underlying config to overlay new settings on top ofpublic static String getOptionalString(com.typesafe.config.Config config, String key)
config - configuration to query for valuekey - configuration path keynull if none existspublic static List<String> getOptionalStringList(com.typesafe.config.Config config, String key)
config - configuration to query for valuekey - configuration path keynull if none existspublic static Double getOptionalDouble(com.typesafe.config.Config config, String key)
config - configuration to query for valuekey - configuration path keynull if none existspublic static void set(Map<String,Object> overlay, String key, Path path) throws IOException
Path value correctly for use with overlayOn(Map,Config).overlay - key-value pairs to overlay on a Configkey - key to setpath - Path valueIOException - if Path can't be made canonicalpublic static String serialize(com.typesafe.config.Config config)
config - Config to serialize to a Stringpublic static com.typesafe.config.Config deserialize(String serialized)
serialized - serialized form of configuration as JSON-like dataConfig from the serialized configpublic static String prettyPrint(com.typesafe.config.Config config)
config - Config to printpublic static Properties keyValueToProperties(Object... keyValues)
keyValues - a sequence key1, value1, key2, value2, ... where the Object.toString()
of successive pairs are interpreted as key-value pairsProperties containing these key-value pairsCopyright © 2014–2018. All rights reserved.