Package org.infinispan.commons.util
Class TypedProperties
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<Object,
Object>
Type-aware properties. Extends the JDK
Properties
class to provide accessors that convert values to certain
types, using default values if a conversion is not possible.- Since:
- 4.0
- Author:
- Manik Surtani
- See Also:
-
Nested Class Summary
-
Field Summary
Fields inherited from class java.util.Properties
defaults
-
Constructor Summary
ConstructorDescriptionDefault constructor that returns an empty instanceTypedProperties
(Map<?, ?> p) Copy constructor -
Method Summary
Modifier and TypeMethodDescriptionboolean
getBooleanProperty
(String key, boolean defaultValue) boolean
getBooleanProperty
(String key, boolean defaultValue, boolean doStringReplace) long
getDurationProperty
(String key, long defaultValue) long
getDurationProperty
(String key, long defaultValue, boolean doStringReplace) <T extends Enum<T>>
TgetEnumProperty
(String key, Class<T> enumClass, T defaultValue) <T extends Enum<T>>
TgetEnumProperty
(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) getProperty
(String key, boolean doStringReplace) Get the property associated with the key, optionally applying string property replacement as defined inStringPropertyReplacer.replaceProperties(java.lang.String)
to the result.getProperty
(String key, String defaultValue, boolean doStringReplace) Get the property associated with the key, optionally applying string property replacement as defined inStringPropertyReplacer.replaceProperties(java.lang.String)
to the result.putIfAbsent
(String key, String value) Put a value if the associated key is not presentsetProperty
(String key, boolean value) setProperty
(String key, int value) setProperty
(String key, long value) setProperty
(String key, String value) static TypedProperties
toTypedProperties
(Map<?, ?> p) Factory method that converts a JDKMap
(includingProperties
instance to an instance of TypedProperties, if needed.Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, getProperty, hashCode, isEmpty, keys, keySet, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
Constructor Details
-
TypedProperties
Copy constructor- Parameters:
p
- properties instance to from. If null, then it is treated as an empty Properties instance.
-
TypedProperties
public TypedProperties()Default constructor that returns an empty instance
-
-
Method Details
-
toTypedProperties
Factory method that converts a JDKMap
(includingProperties
instance to an instance of TypedProperties, if needed.- Parameters:
p
- properties to convert.- Returns:
- A TypedProperties object. Returns an empty TypedProperties instance if p is null.
-
getIntProperty
-
getIntProperty
-
getLongProperty
-
getLongProperty
-
getDurationProperty
-
getDurationProperty
-
getBooleanProperty
-
getBooleanProperty
-
getEnumProperty
-
getEnumProperty
-
getProperty
Get the property associated with the key, optionally applying string property replacement as defined inStringPropertyReplacer.replaceProperties(java.lang.String)
to the result.- Parameters:
key
- the hashtable key.defaultValue
- a default value.doStringReplace
- boolean indicating whether to apply string property replacement- Returns:
- the value in this property list with the specified key value after optionally being inspected for String property replacement
-
getProperty
Get the property associated with the key, optionally applying string property replacement as defined inStringPropertyReplacer.replaceProperties(java.lang.String)
to the result.- Parameters:
key
- the hashtable key.doStringReplace
- boolean indicating whether to apply string property replacement- Returns:
- the value in this property list with the specified key value after optionally being inspected for String property replacement
-
putIfAbsent
Put a value if the associated key is not present- Parameters:
key
- new keyvalue
- new value- Returns:
- this TypedProperties instance for method chaining
-
setProperty
- Overrides:
setProperty
in classProperties
-
setProperty
-
setProperty
-
setProperty
-