public final class PropertiesHelper
extends java.lang.Object
Properties related functions.| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
get(java.lang.Class<?> cls,
java.lang.String key,
java.lang.String def)
Get a
String system property. |
static java.lang.String |
get(java.util.Properties properties,
java.lang.String key,
java.lang.String def)
Get a
String property. |
static int |
getInt(java.lang.Class<?> cls,
java.lang.String key,
int def)
Get a
int system property. |
static int |
getInt(java.util.Properties properties,
java.lang.String key,
int def)
Get a
int property. |
static java.util.Properties |
init(java.lang.Class<?> cls)
Initialize a
Properties object for a specific class. |
static java.util.Properties |
load(java.lang.Class<?> cls)
Load a
Properties object for a specific class. |
public static java.util.Properties init(java.lang.Class<?> cls)
Properties object for a specific class.
The function is identical to load(Class) except for that it generates a RuntimeException if the
load operation fails.
cls - The class to load the properties for.public static java.util.Properties load(java.lang.Class<?> cls)
throws java.io.IOException
Properties object for a specific class.
This function assumes that the properties file is a resource named as the submitted class with the extension .properties.
cls - The class to load the properties for.java.io.IOException - if an I/O error occurs during loading.@Nullable public static java.lang.String get(java.lang.Class<?> cls, java.lang.String key, @Nullable java.lang.String def)
String system property.
The system property key to retrieve is created by concatenating the package name of the submitted class with the submitted key.
cls - The class to use for system property key creation.key - The key to use for system property key creation.def - The default value to use in case the system property is undefined.public static int getInt(java.lang.Class<?> cls,
java.lang.String key,
int def)
int system property.
The system property key to retrieve is created by concatenating the package name of the submitted class with the submitted key.
cls - The class to use for system property key creation.key - The key to use for system property key creation.def - The default value to use in case the system property is undefined.@Nullable public static java.lang.String get(java.util.Properties properties, java.lang.String key, java.lang.String def)
String property.properties - The properties object to evaluate.key - The property key to retrieve.def - The default value to use in case the property is undefined.public static int getInt(java.util.Properties properties,
java.lang.String key,
int def)
int property.properties - The properties object to evaluate.key - The property key to retrieve.def - The default value to use in case the property is undefined.