Skip to content

Commit

Permalink
Added missing cloning of the properties
Browse files Browse the repository at this point in the history
Signed-off-by: maclean <gilleain.torrance@gmail.com>
  • Loading branch information
egonw committed Sep 18, 2011
1 parent 496f242 commit aeaa993
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/org/openscience/cdk/ReactionScheme.java
Expand Up @@ -25,7 +25,10 @@
package org.openscience.cdk;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.interfaces.IReaction;
Expand Down Expand Up @@ -125,6 +128,18 @@ public Object clone() throws CloneNotSupportedException {
for (IReaction reaction : reactions()) {
clone.addReaction((IReaction)reaction.clone());
}
// clone the properties
if (getProperties() != null) {
Map<Object, Object> properties = getProperties();
Map<Object, Object> clonedHashtable = new HashMap<Object, Object>();
Iterator<Object> keys = properties.keySet().iterator();
while (keys.hasNext()) {
Object key = keys.next();
Object value = properties.get(key);
clonedHashtable.put(key, value);
}
clone.setProperties(clonedHashtable);
}

return clone;
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/org/openscience/cdk/silent/ReactionScheme.java
Expand Up @@ -19,7 +19,10 @@
package org.openscience.cdk.silent;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.interfaces.IReaction;
Expand Down Expand Up @@ -119,6 +122,18 @@ public Object clone() throws CloneNotSupportedException {
for (IReaction reaction : reactions()) {
clone.addReaction((IReaction)reaction.clone());
}
// clone the properties
if (getProperties() != null) {
Map<Object, Object> properties = getProperties();
Map<Object, Object> clonedHashtable = new HashMap<Object, Object>();
Iterator<Object> keys = properties.keySet().iterator();
while (keys.hasNext()) {
Object key = keys.next();
Object value = properties.get(key);
clonedHashtable.put(key, value);
}
clone.setProperties(clonedHashtable);
}

return clone;
}
Expand Down

0 comments on commit aeaa993

Please sign in to comment.