public final class PropertyBag
extends java.lang.Object
The simplest way to obtain a required (i.e., the property must be in the bag,
otherwise an exception is thrown) property value is getProperty(String, Class).
If the property is not a required one, the getProperty(String, Class, Object) method
can be used, which also takes a default value which is returned when the property is not
present in the bag.
| Modifier and Type | Method and Description |
|---|---|
<T> T |
getProperty(java.lang.String name,
java.lang.Class<T> type)
Gets the value of a required property in a type-safe manner.
|
<T> T |
getProperty(java.lang.String name,
java.lang.Class<T> type,
T def)
Gets a property value, returning a default value when no property with the specified name exists in the bag.
|
java.lang.String |
getStringProperty(java.lang.String name)
Gets a required property value known to be of string type.
|
java.lang.String |
toString() |
public <T> T getProperty(java.lang.String name,
java.lang.Class<T> type)
IllegalArgumentException is thrown.T - the type of the property.name - the name of the property.type - the Class representing the type of the property.null if the value of the property was null.java.lang.IllegalArgumentException - if no property with the given name name exists in the bag.java.lang.ClassCastException - if the property exists, but is not of the specified type.public <T> T getProperty(java.lang.String name,
java.lang.Class<T> type,
T def)
T - the type of the property.name - the name of the property.type - the Class representing the type of the property.def - the default value returned when no property with the specified name exists in the bag.null if the value of the property
was null.java.lang.ClassCastException - if the property exists, but is not of the specified type.public java.lang.String getStringProperty(java.lang.String name)
String. It does not attempt to call Object.toString() on the value.name - the name of the property.null if the value of the property was null.java.lang.IllegalArgumentException - if no property with the given name exists in the bag.java.lang.ClassCastException - if the property exists, but is not an instance of String.public java.lang.String toString()
toString in class java.lang.Object