/*
*******************************************************************************
- * Copyright (C) 1996-2014, International Business Machines Corporation and *
+ * Copyright (C) 1996-2015, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
* @author markdavis
*/
-public final class UnicodeMap<T> implements Cloneable, Freezable, StringTransform, Iterable<String> {
+public final class UnicodeMap<T> implements Cloneable, Freezable<UnicodeMap<T>>, StringTransform, Iterable<String> {
/**
* For serialization
*/
private transient boolean errorOnReset;
private volatile transient boolean locked;
private int lastIndex;
- private Map<String,T> stringMap;
+ private TreeMap<String,T> stringMap;
{ clear(); }
that.values = (T[]) values.clone();
that.availableValues = new LinkedHashSet<T>(availableValues);
that.locked = false;
+ that.stringMap = stringMap == null ? null : (TreeMap<String, T>) stringMap.clone();
return that;
}
/*
*******************************************************************************
- * Copyright (C) 1996-2014, International Business Machines Corporation and *
+ * Copyright (C) 1996-2015, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
}
return true;
}
+
+ public void TestCloneAsThawed11721 () {
+ UnicodeMap<Integer> test = new UnicodeMap().put("abc", 3).freeze();
+ UnicodeMap<Integer> copy = test.cloneAsThawed();
+ copy.put("def", 4);
+ assertEquals("original-abc", (Integer) 3, test.get("abc"));
+ assertNull("original-def", test.get("def"));
+ assertEquals("copy-def", (Integer) 4, copy.get("def"));
+ }
}