Permalink
Browse files

Convert anonymous class to static inner class to avoid not serializab…

…le error

Signed-off-by: Imran M Yousuf <imyousuf@smartitengineering.com>
  • Loading branch information...
1 parent da98c43 commit 4eeaf0b317a85c3d3032241bc7915cc32f42839e @imyousuf imyousuf committed Mar 13, 2012
@@ -116,13 +116,7 @@ public MediaType(String type, String subtype, Map<String, String> parameters) {
this.parameters = Collections.emptyMap();
}
else {
- Map<String, String> map = new TreeMap<String, String>(new Comparator<String>() {
-
- @Override
- public int compare(String key1, String key2) {
- return key1.compareToIgnoreCase(key2);
- }
- });
+ Map<String, String> map = new TreeMap<String, String>(new StringComparator());
for (Map.Entry<String, String> entry : parameters.entrySet()) {
map.put(entry.getKey().toLowerCase(), entry.getValue());
}
@@ -195,4 +189,12 @@ private static void appendEscapingQuotes(StringBuilder builder, String value) {
builder.append(c);
}
}
+
+ private static class StringComparator implements Comparator<String>, Serializable {
+
+ @Override
+ public int compare(String key1, String key2) {
+ return key1.compareToIgnoreCase(key2);
+ }
+ }
}

0 comments on commit 4eeaf0b

Please sign in to comment.