public class TypedProperties extends Properties
Properties
class to provide accessors that convert values to certain
types, using default values if a conversion is not possible.defaults
Constructor and Description |
---|
TypedProperties()
Default constructor that returns an empty instance
|
TypedProperties(Properties p)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
getBooleanProperty(String key,
boolean defaultValue) |
boolean |
getBooleanProperty(String key,
boolean defaultValue,
boolean doStringReplace) |
<T extends Enum<T>> |
getEnumProperty(String key,
Class<T> enumClass,
T defaultValue) |
<T extends Enum<T>> |
getEnumProperty(String key,
Class<T> enumClass,
T defaultValue,
boolean doStringReplace) |
int |
getIntProperty(String key,
int defaultValue) |
int |
getIntProperty(String key,
int defaultValue,
boolean doStringReplace) |
long |
getLongProperty(String key,
long defaultValue) |
long |
getLongProperty(String key,
long defaultValue,
boolean doStringReplace) |
String |
getProperty(String key,
boolean doStringReplace)
Get the property associated with the key, optionally applying string property replacement as defined in
StringPropertyReplacer.replaceProperties(java.lang.String) to the result. |
String |
getProperty(String key,
String defaultValue,
boolean doStringReplace)
Get the property associated with the key, optionally applying string property replacement as defined in
StringPropertyReplacer.replaceProperties(java.lang.String) to the result. |
TypedProperties |
putIfAbsent(String key,
String value)
Put a value if the associated key is not present
|
TypedProperties |
setProperty(String key,
boolean value) |
TypedProperties |
setProperty(String key,
int value) |
TypedProperties |
setProperty(String key,
long value) |
TypedProperties |
setProperty(String key,
String value) |
static TypedProperties |
toTypedProperties(Properties p)
Factory method that converts a JDK
Properties instance to an instance of TypedProperties, if needed. |
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, store, store, storeToXML, storeToXML, stringPropertyNames
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, merge, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, size, toString, values
public TypedProperties(Properties p)
p
- properties instance to from. If null, then it is treated as an empty Properties instance.public TypedProperties()
public static TypedProperties toTypedProperties(Properties p)
Properties
instance to an instance of TypedProperties, if needed.p
- properties to convert.public int getIntProperty(String key, int defaultValue)
public int getIntProperty(String key, int defaultValue, boolean doStringReplace)
public long getLongProperty(String key, long defaultValue)
public long getLongProperty(String key, long defaultValue, boolean doStringReplace)
public boolean getBooleanProperty(String key, boolean defaultValue)
public boolean getBooleanProperty(String key, boolean defaultValue, boolean doStringReplace)
public <T extends Enum<T>> T getEnumProperty(String key, Class<T> enumClass, T defaultValue)
public <T extends Enum<T>> T getEnumProperty(String key, Class<T> enumClass, T defaultValue, boolean doStringReplace)
public String getProperty(String key, String defaultValue, boolean doStringReplace)
StringPropertyReplacer.replaceProperties(java.lang.String)
to the result.key
- the hashtable key.defaultValue
- a default value.doStringReplace
- boolean indicating whether to apply string property replacementpublic String getProperty(String key, boolean doStringReplace)
StringPropertyReplacer.replaceProperties(java.lang.String)
to the result.key
- the hashtable key.doStringReplace
- boolean indicating whether to apply string property replacementpublic TypedProperties putIfAbsent(String key, String value)
key
- new keyvalue
- new valuepublic TypedProperties setProperty(String key, String value)
setProperty
in class Properties
public TypedProperties setProperty(String key, int value)
public TypedProperties setProperty(String key, long value)
public TypedProperties setProperty(String key, boolean value)
Copyright © 2021 JBoss by Red Hat. All rights reserved.