public class PropertiesUtils extends Object
Properties objects.| Constructor and Description |
|---|
PropertiesUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Properties |
combineProperties(Properties... properties)
Combine a variable number of
Properties into a single Properties. |
static Properties |
deserialize(String serialized) |
static Properties |
extractPropertiesWithPrefix(Properties properties,
com.google.common.base.Optional<String> prefix)
|
static Properties |
extractPropertiesWithPrefixAfterRemovingPrefix(Properties properties,
String prefix)
|
static boolean |
getPropAsBoolean(Properties properties,
String key,
String defaultValue) |
static int |
getPropAsInt(Properties properties,
String key,
int defaultValue) |
static List<String> |
getPropAsList(Properties properties,
String key)
Get the value of a comma separated property as a
List of strings. |
static List<String> |
getPropAsList(Properties properties,
String key,
String def)
Get the value of a property as a list of strings, using the given default value if the property is not set.
|
static long |
getPropAsLong(Properties properties,
String key,
long defaultValue) |
static List<String> |
getValuesAsList(Properties properties,
com.google.common.base.Optional<String> prefix)
Extract all the values whose keys start with a
prefix |
static String |
prettyPrintProperties(Properties properties) |
static Map<String,?> |
propsToStringKeyMap(Properties properties)
|
static String |
serialize(Properties properties) |
public static Properties combineProperties(Properties... properties)
Properties into a single Properties.public static Map<String,?> propsToStringKeyMap(Properties properties)
public static boolean getPropAsBoolean(Properties properties, String key, String defaultValue)
public static int getPropAsInt(Properties properties, String key, int defaultValue)
public static long getPropAsLong(Properties properties, String key, long defaultValue)
public static List<String> getPropAsList(Properties properties, String key)
List of strings.key - property keyList of stringspublic static List<String> getValuesAsList(Properties properties, com.google.common.base.Optional<String> prefix)
prefixproperties - the given Properties instanceprefix - of keys to be extractedpublic static List<String> getPropAsList(Properties properties, String key, String def)
key - property keydef - default valuepublic static Properties extractPropertiesWithPrefix(Properties properties, com.google.common.base.Optional<String> prefix)
properties - the given Properties instanceprefix - of keys to be extractedProperties instancepublic static Properties extractPropertiesWithPrefixAfterRemovingPrefix(Properties properties, String prefix)
prefix in Properties to a new Properties
instance. It removes the prefix from the properties.properties - the given Properties instanceprefix - of keys to be extractedProperties instancepublic static String serialize(Properties properties) throws IOException
IOExceptionpublic static Properties deserialize(String serialized) throws IOException
IOExceptionpublic static String prettyPrintProperties(Properties properties)