@@ -61,7 +61,7 @@ protected JavaType _typeFromId(String id, DatabindContext ctxt) throws IOExcepti
61
61
/**********************************************************
62
62
*/
63
63
64
- protected final String _idFrom (Object value , Class <?> cls , TypeFactory typeFactory )
64
+ protected String _idFrom (Object value , Class <?> cls , TypeFactory typeFactory )
65
65
{
66
66
// Need to ensure that "enum subtypes" work too
67
67
if (Enum .class .isAssignableFrom (cls )) {
@@ -87,16 +87,18 @@ protected final String _idFrom(Object value, Class<?> cls, TypeFactory typeFacto
87
87
// not optimal: but EnumMap is not a customizable type so this is sort of ok
88
88
str = typeFactory .constructMapType (EnumMap .class , enumClass , valueClass ).toCanonical ();
89
89
} else {
90
- String end = str .substring (9 );
91
- if ((end .startsWith (".Arrays$" ) || end .startsWith (".Collections$" ))
92
- && str .indexOf ("List" ) >= 0 ) {
93
- /* 17-Feb-2010, tatus: Another such case: result of
94
- * Arrays.asList() is named like so in Sun JDK...
95
- * Let's just plain old ArrayList in its place
96
- * NOTE: chances are there are plenty of similar cases
97
- * for other wrappers... (immutable, singleton, synced etc)
98
- */
90
+ /* 17-Feb-2010, tatus: Another such case: result of
91
+ * Arrays.asList() is named like so in Sun JDK...
92
+ * Let's just plain old ArrayList in its place
93
+ * NOTE: chances are there are plenty of similar cases
94
+ * for other wrappers... (immutable, singleton, synced etc)
95
+ */
96
+ if (isJavaUtilCollectionClass (str , "List" )) {
99
97
str = "java.util.ArrayList" ;
98
+ }else if (isJavaUtilCollectionClass (str , "Map" )){
99
+ str = "java.util.HashMap" ;
100
+ }else if (isJavaUtilCollectionClass (str , "Set" )){
101
+ str = "java.util.HashSet" ;
100
102
}
101
103
}
102
104
} else if (str .indexOf ('$' ) >= 0 ) {
@@ -128,4 +130,9 @@ protected final String _idFrom(Object value, Class<?> cls, TypeFactory typeFacto
128
130
public String getDescForKnownTypeIds () {
129
131
return "class name used as type id" ;
130
132
}
133
+
134
+ private static boolean isJavaUtilCollectionClass (String clazzName , String type ){
135
+ String end = clazzName .substring (9 );
136
+ return (end .startsWith (".Collections$" ) || end .startsWith (".Arrays$" )) && clazzName .indexOf (type ) > 0 ;
137
+ }
131
138
}
0 commit comments