# HG changeset patch # User František Kučera # Date 1388509910 -3600 # Node ID 39d8b427e20f928599b6cc2defd8c613efbdb988 # Parent 245f1b88a3e680218d1a907e2a6c860df9cc355d cloneable property and properties diff -r 245f1b88a3e6 -r 39d8b427e20f java/sql-dk/src/info/globalcode/sql/dk/configuration/Properties.java --- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/Properties.java Tue Dec 31 17:35:33 2013 +0100 +++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/Properties.java Tue Dec 31 18:11:50 2013 +0100 @@ -20,6 +20,7 @@ import java.util.ArrayList; import javax.xml.bind.annotation.XmlTransient; import static info.globalcode.sql.dk.Functions.findByName; +import java.util.Collections; /** *

List of configurables.

@@ -38,10 +39,17 @@ * * @author Ing. František Kučera (frantovo.cz) */ -public class Properties extends ArrayList { +public class Properties extends ArrayList implements Cloneable { private Properties defaults; + public Properties() { + } + + public Properties(int initialCapacity) { + super(initialCapacity); + } + @XmlTransient public Properties getDefaults() { return defaults; @@ -73,4 +81,11 @@ Property p = findProperty(name); return p == null ? defaultValue : Integer.valueOf(p.getValue()); } + + @Override + public Properties clone() { + Properties clone = new Properties(size()); + Collections.copy(clone, this); + return clone; + } } diff -r 245f1b88a3e6 -r 39d8b427e20f java/sql-dk/src/info/globalcode/sql/dk/configuration/Property.java --- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/Property.java Tue Dec 31 17:35:33 2013 +0100 +++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/Property.java Tue Dec 31 18:11:50 2013 +0100 @@ -25,7 +25,7 @@ * * @author Ing. František Kučera (frantovo.cz) */ -public class Property implements NameIdentified { +public class Property implements NameIdentified, Cloneable { private String name; private String value; @@ -61,4 +61,9 @@ public String toString() { return name + "='" + value + "'"; } + + @Override + protected Property clone() { + return new Property(name, value); + } }