Also do proper cloning so we can be subclassed.

This commit is contained in:
Ray J. Greenwell
2014-10-29 09:59:15 -07:00
parent 8c72823ab1
commit 2290ee3f3d
@@ -51,6 +51,7 @@ import com.samskivert.util.StringUtil;
* prefix like "something*" or a suffix like "*something". * prefix like "something*" or a suffix like "*something".
*/ */
public class ImportSet public class ImportSet
implements Cloneable
{ {
/** /**
* Adds the given class' name to the set of imports. * Adds the given class' name to the set of imports.
@@ -99,9 +100,15 @@ public class ImportSet
@Override @Override
public ImportSet clone () public ImportSet clone ()
{ {
ImportSet newset = new ImportSet(); try {
newset.addAll(this); ImportSet newSet = (ImportSet)super.clone();
return newset; newSet._pushed = Lists.newArrayList();
newSet._imports = Sets.newHashSet(this._imports);
return newSet;
} catch (CloneNotSupportedException cnse) {
throw new AssertionError(cnse); // we are Cloneable
}
} }
/** /**