@@ -50,7 +50,7 @@ private synchronized static Decoder gen(String cacheKey, Type type) {
5050 clazz = (Class ) type ;
5151 }
5252 if (mode == DecodingMode .REFLECTION_MODE ) {
53- return ReflectionDecoder .create (clazz , typeArgs );
53+ return ReflectionDecoderFactory .create (clazz , typeArgs );
5454 }
5555 try {
5656 return (Decoder ) Class .forName (cacheKey ).newInstance ();
@@ -108,6 +108,27 @@ private static Type chooseImpl(Type type) {
108108 }
109109 return new ParameterizedTypeImpl (new Type []{compType }, null , clazz );
110110 }
111+ if (Map .class .isAssignableFrom (clazz )) {
112+ Type keyType = String .class ;
113+ Type valueType = Object .class ;
114+ if (typeArgs .length == 0 ) {
115+ // default to Map<String, Object>
116+ } else if (typeArgs .length == 2 ) {
117+ keyType = typeArgs [0 ];
118+ valueType = typeArgs [1 ];
119+ } else {
120+ throw new IllegalArgumentException (
121+ "can not bind to generic collection without argument types, " +
122+ "try syntax like TypeLiteral<Map<String, String>>{}" );
123+ }
124+ if (keyType != String .class ) {
125+ throw new IllegalArgumentException ("map key must be String" );
126+ }
127+ if (clazz == Map .class ) {
128+ clazz = HashMap .class ;
129+ }
130+ return new ParameterizedTypeImpl (new Type []{keyType , valueType }, null , clazz );
131+ }
111132 return type ;
112133 }
113134
0 commit comments