mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1244944 - Remove unused deepCopy method. r=rnewman
MozReview-Commit-ID: 5LAtdJ5W3fX
This commit is contained in:
parent
6903c86a8c
commit
c6f78cf224
@ -173,37 +173,6 @@ public class ExtendedJSONObject {
|
||||
this.object = o;
|
||||
}
|
||||
|
||||
public ExtendedJSONObject deepCopy() {
|
||||
final ExtendedJSONObject out = new ExtendedJSONObject();
|
||||
@SuppressWarnings("unchecked")
|
||||
final Set<Map.Entry<String, Object>> entries = this.object.entrySet();
|
||||
for (Map.Entry<String, Object> entry : entries) {
|
||||
final String key = entry.getKey();
|
||||
final Object value = entry.getValue();
|
||||
if (value instanceof JSONArray) {
|
||||
// Oh god.
|
||||
try {
|
||||
out.put(key, new JSONParser().parse(((JSONArray) value).toJSONString()));
|
||||
} catch (ParseException e) {
|
||||
// This should never occur, because we're round-tripping.
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (value instanceof JSONObject) {
|
||||
out.put(key, new ExtendedJSONObject((JSONObject) value).deepCopy().object);
|
||||
continue;
|
||||
}
|
||||
if (value instanceof ExtendedJSONObject) {
|
||||
out.put(key, ((ExtendedJSONObject) value).deepCopy());
|
||||
continue;
|
||||
}
|
||||
// Oh well.
|
||||
out.put(key, value);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
public ExtendedJSONObject(Reader in) throws IOException, ParseException, NonObjectJSONException {
|
||||
if (in == null) {
|
||||
this.object = new JSONObject();
|
||||
|
@ -32,17 +32,6 @@ public class TestExtendedJSONObject {
|
||||
public static String exampleJSON = "{\"modified\":1233702554.25,\"success\":[\"{GXS58IDC}12\",\"{GXS58IDC}13\",\"{GXS58IDC}15\",\"{GXS58IDC}16\",\"{GXS58IDC}18\",\"{GXS58IDC}19\"],\"failed\":{\"{GXS58IDC}11\":[\"invalid parentid\"],\"{GXS58IDC}14\":[\"invalid parentid\"],\"{GXS58IDC}17\":[\"invalid parentid\"],\"{GXS58IDC}20\":[\"invalid parentid\"]}}";
|
||||
public static String exampleIntegral = "{\"modified\":1233702554,}";
|
||||
|
||||
@Test
|
||||
public void testDeepCopy() throws NonObjectJSONException, IOException, ParseException, NonArrayJSONException {
|
||||
ExtendedJSONObject a = new ExtendedJSONObject(exampleJSON);
|
||||
ExtendedJSONObject c = a.deepCopy();
|
||||
assertTrue(a != c);
|
||||
assertTrue(a.equals(c));
|
||||
assertTrue(a.get("modified") == c.get("modified"));
|
||||
assertTrue(a.getArray("success") != c.getArray("success"));
|
||||
assertTrue(a.getArray("success").equals(c.getArray("success")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFractional() throws IOException, ParseException, NonObjectJSONException {
|
||||
ExtendedJSONObject o = new ExtendedJSONObject(exampleJSON);
|
||||
|
Loading…
Reference in New Issue
Block a user