Class PropertyListImpl
- java.lang.Object
-
- net.officefloor.compile.impl.properties.PropertyListImpl
-
- All Implemented Interfaces:
java.lang.Iterable<Property>,PropertyList
public class PropertyListImpl extends java.lang.Object implements PropertyList
Implementation of thePropertyList.- Author:
- Daniel Sagenschneider
-
-
Constructor Summary
Constructors Constructor Description PropertyListImpl(java.lang.String... nameValuePairs)Initiate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PropertyaddProperty(java.lang.String name)Appends aPropertyto thisPropertyList.PropertyaddProperty(java.lang.String name, java.lang.String label)Appends aPropertyto thisPropertyList.voidclear()Clears thePropertyList.voidconfigureProperties(PropertyConfigurable configurable)PropertygetOrAddProperty(java.lang.String name)java.util.PropertiesgetProperties()Obtains thePropertiespopulated with thePropertyvalues.PropertygetProperty(java.lang.String name)Obtains the firstPropertyby the input name.java.lang.String[]getPropertyNames()Obtains the names of thePropertyinstances in the order they were added.java.lang.StringgetPropertyValue(java.lang.String name, java.lang.String defaultValue)Convenience method to obtain thePropertyvalue.java.util.Iterator<Property>iterator()voidnormalise()Normalises thePropertyinstances.voidremoveProperty(Property property)Removes thePropertyfrom thisPropertyList.voidsort(java.util.Comparator<? super Property> comparator)Enable sorting thePropertyinstances within thisPropertyList.
-
-
-
Constructor Detail
-
PropertyListImpl
public PropertyListImpl(java.lang.String... nameValuePairs)
Initiate.- Parameters:
nameValuePairs-Propertyname/values to initially populate this list.
-
-
Method Detail
-
iterator
public java.util.Iterator<Property> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<Property>
-
addProperty
public Property addProperty(java.lang.String name, java.lang.String label)
Description copied from interface:PropertyListAppends aPropertyto thisPropertyList.- Specified by:
addPropertyin interfacePropertyList- Parameters:
name- Name of theProperty.label- Label of theProperty. Should this be blank it will be defaulted to the name.- Returns:
Propertyadded.
-
addProperty
public Property addProperty(java.lang.String name)
Description copied from interface:PropertyListAppends aPropertyto thisPropertyList.- Specified by:
addPropertyin interfacePropertyList- Parameters:
name- Name of thePropertywhich is also used as the label.- Returns:
Propertyadded.
-
removeProperty
public void removeProperty(Property property)
Description copied from interface:PropertyListRemoves thePropertyfrom thisPropertyList.- Specified by:
removePropertyin interfacePropertyList- Parameters:
property-Propertyto be removed.
-
getPropertyNames
public java.lang.String[] getPropertyNames()
Description copied from interface:PropertyListObtains the names of thePropertyinstances in the order they were added.- Specified by:
getPropertyNamesin interfacePropertyList- Returns:
- Names of the
Propertyinstances.
-
getProperty
public Property getProperty(java.lang.String name)
Description copied from interface:PropertyListObtains the firstPropertyby the input name.- Specified by:
getPropertyin interfacePropertyList- Parameters:
name- Name of thePropertyto return.- Returns:
- First
Propertyby the input name, ornullif noPropertyby the name.
-
getOrAddProperty
public Property getOrAddProperty(java.lang.String name)
Description copied from interface:PropertyList- Specified by:
getOrAddPropertyin interfacePropertyList- Parameters:
name- Name of thePropertyto return.- Returns:
- First
Propertyby the input name or a newly addedPropertyif noPropertyfound by the name.
-
getPropertyValue
public java.lang.String getPropertyValue(java.lang.String name, java.lang.String defaultValue)Description copied from interface:PropertyListConvenience method to obtain thePropertyvalue.- Specified by:
getPropertyValuein interfacePropertyList- Parameters:
name- Name of thePropertyto obtain its value.defaultValue- Default value should thePropertynot exist or have blank value.- Returns:
- Value for the
Property(ordefaultValueif not available).
-
getProperties
public java.util.Properties getProperties()
Description copied from interface:PropertyListObtains thePropertiespopulated with thePropertyvalues.- Specified by:
getPropertiesin interfacePropertyList- Returns:
- Populated
Properties.
-
clear
public void clear()
Description copied from interface:PropertyListClears thePropertyList.- Specified by:
clearin interfacePropertyList
-
sort
public void sort(java.util.Comparator<? super Property> comparator)
Description copied from interface:PropertyListEnable sorting thePropertyinstances within thisPropertyList.- Specified by:
sortin interfacePropertyList- Parameters:
comparator-Comparatorto provide comparisons for sorting.
-
normalise
public void normalise()
Description copied from interface:PropertyListNormalises the
Propertyinstances.This will remove:
- Specified by:
normalisein interfacePropertyList
-
configureProperties
public void configureProperties(PropertyConfigurable configurable)
Description copied from interface:PropertyList- Specified by:
configurePropertiesin interfacePropertyList- Parameters:
configurable-PropertyConfigurableto be configured with thePropertyvalues.
-
-