Package org.appng.api.support
Class PropertyHolder
- java.lang.Object
-
- org.appng.api.support.PropertyHolder
-
- All Implemented Interfaces:
Properties
- Direct Known Subclasses:
PersistentPropertyHolder
public class PropertyHolder extends Object implements Properties
- Author:
- Matthias Müller
-
-
Constructor Summary
Constructors Constructor Description PropertyHolder()
PropertyHolder(String prefix, Iterable<? extends Property> properties)
Creates a newPropertyHolder
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Property
addProperty(String name, Object defaultValue, String description, Property.Type type)
As long assetFinal()
has not be called, this method can be used to add new propertiesbyte[]
getBlob(String name)
Returns the byte-value of the givenProperty
.Boolean
getBoolean(String name)
Boolean
getBoolean(String name, Boolean defaultValue)
String
getClob(String name)
Returns the string-value of the givenProperty
.String
getClob(String name, String defaultValue)
Returns the string-value of the givenProperty
(if existing), or the default-value.String
getDescriptionFor(String name)
Returns the description for theProperty
with the given name, if anyDouble
getDouble(String name)
Double
getDouble(String name, Double defaultValue)
Float
getFloat(String name)
Float
getFloat(String name, Float defaultValue)
Integer
getInteger(String name)
Integer
getInteger(String name, Integer defaultValue)
List<String>
getList(String name, String delimiter)
List<String>
getList(String name, String defaultValue, String delimiter)
protected SimpleProperty
getNewProperty(String name)
Object
getObject(String name)
<T> T
getObject(String name, T defaultValue)
Properties
getPlainProperties()
Takes thisProperties
and transforms it into some (plain, old, uncool)Properties
.Properties
getProperties(String name)
Returns someProperties
parsed from the givenProperty
(if existing).Property
getProperty(String name)
Set<String>
getPropertyNames()
Returns allProperty
names.String
getString(String name)
Returns the string-value of the givenProperty
.String
getString(String name, String defaultValue)
Returns the string-value of the givenProperty
(if existing), or the default-value.boolean
propertyExists(String name)
Checks whether theProperty
with the given name exists.PropertyHolder
setFinal()
Sets thisPropertyHolder
to final, which means no more properties can be added usingaddProperty(String, Object, String, Type)
.String
toString()
-
-
-
Constructor Detail
-
PropertyHolder
public PropertyHolder(String prefix, Iterable<? extends Property> properties)
Creates a newPropertyHolder
- Parameters:
prefix
- the prefix to useproperties
- theProperty
-instances to hold
-
PropertyHolder
public PropertyHolder()
-
-
Method Detail
-
setFinal
public PropertyHolder setFinal()
Sets thisPropertyHolder
to final, which means no more properties can be added usingaddProperty(String, Object, String, Type)
.- Returns:
- this
PropertyHolder
-
getPropertyNames
public Set<String> getPropertyNames()
Description copied from interface:Properties
Returns allProperty
names.- Specified by:
getPropertyNames
in interfaceProperties
- Returns:
- all
Property
names
-
propertyExists
public boolean propertyExists(String name)
Description copied from interface:Properties
Checks whether theProperty
with the given name exists.- Specified by:
propertyExists
in interfaceProperties
- Parameters:
name
- the name of theProperty
- Returns:
true
if theProperty
exists,false
otherwise
-
getString
public String getString(String name, String defaultValue)
Description copied from interface:Properties
Returns the string-value of the givenProperty
(if existing), or the default-value.- Specified by:
getString
in interfaceProperties
- Parameters:
name
- the name of theProperty
defaultValue
- the default-value- Returns:
- the string-value of the given
Property
(if existing), or the default-value
-
addProperty
public final Property addProperty(String name, Object defaultValue, String description, Property.Type type)
As long assetFinal()
has not be called, this method can be used to add new properties- Parameters:
name
- the name of the property, without prefixdefaultValue
- the default value for the property to add, must not benull
description
- the description for the propertytype
- the type of the property- Throws:
IllegalArgumentException
- if defaultValue isnull
or ifsetFinal()
has been called before.
-
getNewProperty
protected SimpleProperty getNewProperty(String name)
-
getBoolean
public Boolean getBoolean(String name)
Description copied from interface:Properties
- Specified by:
getBoolean
in interfaceProperties
- Parameters:
name
- the name of theProperty
- Returns:
- a
Boolean
, ornull
if no suchProperty
exists.
-
getBoolean
public Boolean getBoolean(String name, Boolean defaultValue)
- Specified by:
getBoolean
in interfaceProperties
- Parameters:
name
- the name of theProperty
defaultValue
- the default-value- Returns:
- a
Boolean
, or the default-value if no suchProperty
exists.
-
getInteger
public Integer getInteger(String name, Integer defaultValue)
Description copied from interface:Properties
- Specified by:
getInteger
in interfaceProperties
- Parameters:
name
- the name of theProperty
defaultValue
- the default-value- Returns:
- an
Integer
, or the default-value if no suchProperty
exists.
-
getFloat
public Float getFloat(String name, Float defaultValue)
Description copied from interface:Properties
- Specified by:
getFloat
in interfaceProperties
- Parameters:
name
- the name of theProperty
defaultValue
- the default-value- Returns:
- an
Float
, or the default-value if no suchProperty
exists.
-
getDouble
public Double getDouble(String name, Double defaultValue)
Description copied from interface:Properties
- Specified by:
getDouble
in interfaceProperties
- Parameters:
name
- the name of theProperty
defaultValue
- the default-value- Returns:
- a
Double
, or the default-value if no suchProperty
exists.
-
getBlob
public byte[] getBlob(String name)
Description copied from interface:Properties
Returns the byte-value of the givenProperty
.- Specified by:
getBlob
in interfaceProperties
- Parameters:
name
- the name of theProperty
- Returns:
- the byte-value of the given
Property
, ornull
if no suchProperty
exists.
-
getClob
public String getClob(String name, String defaultValue)
Description copied from interface:Properties
Returns the string-value of the givenProperty
(if existing), or the default-value.- Specified by:
getClob
in interfaceProperties
- Parameters:
name
- the name of theProperty
defaultValue
- the default-value- Returns:
- the string-value of the given
Property
(if existing), or the default-value
-
getString
public String getString(String name)
Description copied from interface:Properties
Returns the string-value of the givenProperty
.- Specified by:
getString
in interfaceProperties
- Parameters:
name
- the name of theProperty
- Returns:
- the string-value of the given
Property
, ornull
if no such property exists.
-
getInteger
public Integer getInteger(String name)
Description copied from interface:Properties
- Specified by:
getInteger
in interfaceProperties
- Parameters:
name
- the name of theProperty
- Returns:
- an
Integer
, ornull
if no suchProperty
exists.
-
getFloat
public Float getFloat(String name)
Description copied from interface:Properties
- Specified by:
getFloat
in interfaceProperties
- Parameters:
name
- the name of theProperty
- Returns:
- an
Float
, ornull
if no suchProperty
exists.
-
getDouble
public Double getDouble(String name)
Description copied from interface:Properties
- Specified by:
getDouble
in interfaceProperties
- Parameters:
name
- the name of theProperty
- Returns:
- an
Double
, ornull
if no suchProperty
exists.
-
getClob
public String getClob(String name)
Description copied from interface:Properties
Returns the string-value of the givenProperty
.- Specified by:
getClob
in interfaceProperties
- Parameters:
name
- the name of theProperty
- Returns:
- the string-value of the given
Property
, ornull
if no suchProperty
exists.
-
getObject
public <T> T getObject(String name, T defaultValue)
-
getList
public List<String> getList(String name, String defaultValue, String delimiter)
Description copied from interface:Properties
Returns aList
ofString
s which is parsed from the value of theProperty
with the given name (if present) or from the default-value.- Specified by:
getList
in interfaceProperties
- Parameters:
name
- the name of theProperty
defaultValue
- the default-string to parse the list fromdelimiter
- the delimiter to split the (default-)value by- Returns:
- a (possibly empty)
List
, nevernull
-
getList
public List<String> getList(String name, String delimiter)
Description copied from interface:Properties
-
getPlainProperties
public Properties getPlainProperties()
Description copied from interface:Properties
Takes thisProperties
and transforms it into some (plain, old, uncool)Properties
.- Specified by:
getPlainProperties
in interfaceProperties
- Returns:
- some
Properties
-
getProperties
public Properties getProperties(String name)
Description copied from interface:Properties
Returns someProperties
parsed from the givenProperty
(if existing).- Specified by:
getProperties
in interfaceProperties
- Parameters:
name
- the name of theProperty
- Returns:
- some
Properties
, ornull
if no suchProperty
exists.
-
getDescriptionFor
public String getDescriptionFor(String name)
Description copied from interface:Properties
Returns the description for theProperty
with the given name, if any- Specified by:
getDescriptionFor
in interfaceProperties
- Parameters:
name
- the name of the property- Returns:
- the description, if any
-
-