elementMetaInfo = new ParserMetaInfo();
if(Collection.class.isAssignableFrom(rawClass)) {
Type[] types2 = pt.getActualTypeArguments();
if(types2.length != 1)
throw new JsonException("collection actual type args length not equals 1");
Type eleType = types2[0];
elementMetaInfo.setType(getImplClass(rawClass));
elementMetaInfo.setParser(new CollectionParser(eleType));
} else if (Map.class.isAssignableFrom(rawClass)) {
Type[] types2 = pt.getActualTypeArguments();
if(types2.length != 2)
throw new JsonException("map actual type args length not equals 2");
Type key = types2[0];
if (!((key instanceof Class) && key == String.class))
throw new JsonException("map key type not string");
Type eleType = types2[1];
elementMetaInfo.setType(getImplClass(rawClass));
elementMetaInfo.setParser(new MapParser(eleType));
} else {
elementMetaInfo.setType(rawClass);
elementMetaInfo.setParser(ParserStateMachine.getParser(rawClass));
}
} else if (elementType instanceof Class) {
Class<?> eleClass = (Class<?>) elementType; // 获取集合元素Parser
elementMetaInfo = new ParserMetaInfo();
elementMetaInfo.setType(eleClass);
elementMetaInfo.setParser(ParserStateMachine.getParser(eleClass));
} else if(elementType instanceof GenericArrayType) {
GenericArrayType t = (GenericArrayType)elementType;
Class<?> eleType = (Class<?>)t.getGenericComponentType();
Object obj = Array.newInstance(eleType, 0);
Class<?> rawClass = obj.getClass();
elementMetaInfo = new ParserMetaInfo();
elementMetaInfo.setType(rawClass);
elementMetaInfo.setParser(ParserStateMachine.getParser(rawClass));
} else {
throw new JsonException("mot support type " + elementType);
}
}