Mercurial > dive4elements > river
diff flys-client/src/main/java/org/dive4elements/river/client/shared/model/PropertyGroup.java @ 5834:f507086aa94b
Repaired internal references.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:31:32 +0200 |
parents | flys-client/src/main/java/de/intevation/flys/client/shared/model/PropertyGroup.java@62332fa199bf |
children | 821a02bbfb4e |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/org/dive4elements/river/client/shared/model/PropertyGroup.java Thu Apr 25 12:31:32 2013 +0200 @@ -0,0 +1,80 @@ +package de.intevation.flys.client.shared.model; + +import java.util.ArrayList; +import java.util.List; + +/** + * A group of properties. + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public class PropertyGroup implements Property, Cloneable { + + /** The group name */ + protected String name; + + protected List<Property> properties; + + public PropertyGroup() { + } + + public PropertyGroup(String name) { + this.name = name; + } + + public PropertyGroup(String name, List<Property> properties) { + this.name = name; + this.properties = properties; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public List<Property> getProperties() { + return this.properties; + } + + public void setProperties(List<Property> properties) { + this.properties = properties; + } + + public Property getPropertyByName(String name) { + for (int i = 0; i < properties.size(); i++) { + if (properties.get(i).getName().equals(name)) { + return properties.get(i); + } + } + return null; + } + + @Override + public Object clone() { + PropertyGroup clone = new PropertyGroup(this.getName()); + List<Property> cloneList = new ArrayList<Property>(); + for(Property p: properties) { + cloneList.add((Property)p.clone()); + } + clone.setProperties(cloneList); + return clone; + } + + @Override + public String toString() { + StringBuilder buf = new StringBuilder(); + + for(Property p : properties) { + buf.append(p.getName()); + buf.append("="); + if(p instanceof PropertySetting) { + buf.append(((PropertySetting)p).getValue().toString()); + } + buf.append(" "); + } + + return buf.toString(); + } +}