public class ConfigParser extends Object
These methods provide safe access to system properties as String, boolean, int, and long,
and include additional logic for parsing time-based values with unit suffixes (e.g., "10s", "5min").
This class is not meant to be instantiated.
| Constructor and Description |
|---|
ConfigParser() |
| Modifier and Type | Method and Description |
|---|---|
long |
getMillisecondsProperty(String name,
long defaultValue)
Retrieves the value of a system property as a duration in milliseconds.
|
boolean |
getProperty(String name,
boolean defaultValue)
Retrieves the value of a system property as a boolean.
|
int |
getProperty(String name,
int defaultValue)
Retrieves the value of a system property as an integer.
|
long |
getProperty(String name,
long defaultValue)
Retrieves the value of a system property as a long integer.
|
String |
getProperty(String name,
String defaultValue)
Retrieves the value of a system property as a string.
|
public String getProperty(String name, String defaultValue)
name - the name of the system propertydefaultValue - the default value to return if the property is not setpublic boolean getProperty(String name, boolean defaultValue)
The property value is parsed using Boolean.parseBoolean(String).
name - the name of the system propertydefaultValue - the default value to return if the property is not setpublic int getProperty(String name, int defaultValue)
name - the name of the system propertydefaultValue - the default value to return if the property is not set or invalidpublic long getProperty(String name, long defaultValue)
name - the name of the system propertydefaultValue - the default value to return if the property is not set or invalidpublic long getMillisecondsProperty(String name, long defaultValue)
Supports suffixes for time units:
ms for millisecondss for secondsm or min for minutesh for hoursname - the name of the system propertydefaultValue - the default value (in milliseconds) to return if the property is not set or invalidCopyright © 2010–2025. All rights reserved.