Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3ffaf15

Browse filesBrowse files
committed
Removes the commons-collections dependency and changes the org.json:json dependency to the same version included with Android. This makes including this as a library in an Android project cleaner/easier.
1 parent 2d13407 commit 3ffaf15
Copy full SHA for 3ffaf15

File tree

Expand file treeCollapse file tree

3 files changed

+18
-16
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+18
-16
lines changed
Open diff view settings
Collapse file

‎pom.xml‎

Copy file name to clipboardExpand all lines: pom.xml
+1-7Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,8 @@
5252
<dependency>
5353
<groupId>org.json</groupId>
5454
<artifactId>json</artifactId>
55-
<version>20090211</version>
55+
<version>20080701</version>
5656
</dependency>
57-
<dependency>
58-
<groupId>commons-collections</groupId>
59-
<artifactId>commons-collections</artifactId>
60-
<version>3.0</version>
61-
</dependency>
62-
6357
<dependency>
6458
<groupId>junit</groupId>
6559
<artifactId>junit</artifactId>
Collapse file

‎src/main/java/org/skyscreamer/jsonassert/comparator/AbstractComparator.java‎

Copy file name to clipboardExpand all lines: src/main/java/org/skyscreamer/jsonassert/comparator/AbstractComparator.java
+3-8Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package org.skyscreamer.jsonassert.comparator;
22

3-
import org.apache.commons.collections.CollectionUtils;
43
import org.json.JSONArray;
54
import org.json.JSONException;
65
import org.json.JSONObject;
76
import org.skyscreamer.jsonassert.JSONCompareResult;
87

9-
import java.util.HashSet;
10-
import java.util.Map;
11-
import java.util.Set;
8+
import java.util.*;
129

1310
import static org.skyscreamer.jsonassert.comparator.JSONCompareUtil.*;
1411

@@ -94,10 +91,8 @@ protected void compareJSONArrayOfJsonObjects(String key, JSONArray expected, JSO
9491
}
9592

9693
protected void compareJSONArrayOfSimpleValues(String key, JSONArray expected, JSONArray actual, JSONCompareResult result) throws JSONException {
97-
@SuppressWarnings("unchecked")
98-
Map<Object, Integer> expectedCount = CollectionUtils.getCardinalityMap(jsonArrayToList(expected));
99-
@SuppressWarnings("unchecked")
100-
Map<Object, Integer> actualCount = CollectionUtils.getCardinalityMap(jsonArrayToList(actual));
94+
Map<Object, Integer> expectedCount = JSONCompareUtil.getCardinalityMap(jsonArrayToList(expected));
95+
Map<Object, Integer> actualCount = JSONCompareUtil.getCardinalityMap(jsonArrayToList(actual));
10196
for (Object o : expectedCount.keySet()) {
10297
if (!actualCount.containsKey(o)) {
10398
result.missing(key + "[]", o);
Collapse file

‎src/main/java/org/skyscreamer/jsonassert/comparator/JSONCompareUtil.java‎

Copy file name to clipboardExpand all lines: src/main/java/org/skyscreamer/jsonassert/comparator/JSONCompareUtil.java
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
* Utility class that contains Json manipulation methods
1111
*/
1212
public final class JSONCompareUtil {
13+
private static Integer INTEGER_ONE = new Integer(1);
14+
1315
private JSONCompareUtil() {}
1416

1517
public static Map<Object,JSONObject> arrayOfJsonObjectToMap(JSONArray array, String uniqueKey) throws JSONException {
@@ -116,5 +118,16 @@ public static String formatUniqueKey(String key, String uniqueKey, Object value)
116118
return key + "[" + uniqueKey + "=" + value + "]";
117119
}
118120

119-
121+
public static <T> Map<T, Integer> getCardinalityMap(final Collection<T> coll) {
122+
Map count = new HashMap<T, Integer>();
123+
for (T item : coll) {
124+
Integer c = (Integer) (count.get(item));
125+
if (c == null) {
126+
count.put(item, INTEGER_ONE);
127+
} else {
128+
count.put(item, new Integer(c.intValue() + 1));
129+
}
130+
}
131+
return count;
132+
}
120133
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.