if (!((key instanceof Class) && key == String.class))
throw new JsonException("not support the " + method);
Type elementType = types2[1];
parserMetaInfo.setType(ComplexTypeParser.getImplClass(type));
parserMetaInfo.setParser(new MapParser(elementType));
} else { // 获取对象、枚举或者数组Parser
parserMetaInfo.setType(type);
parserMetaInfo.setParser(ParserStateMachine.getParser(type));
}
fieldSet.add(parserMetaInfo);
}
for(Field field : clazz.getFields()) { // public字段反序列化构造
if(Modifier.isTransient(field.getModifiers()) || field.isAnnotationPresent(Transient.class) || Modifier.isStatic(field.getModifiers()))
continue;
field.setAccessible(true);
ParserMetaInfo parserMetaInfo = new ParserMetaInfo();
parserMetaInfo.setPropertyNameString(field.getName());
parserMetaInfo.setPropertyInvoke(new FieldInvoke(field));
Class<?> type = field.getType();
if (Collection.class.isAssignableFrom(type)) {
Type fieldType = field.getGenericType();
if(!(fieldType instanceof ParameterizedType))
throw new JsonException("not support the " + field);
ParameterizedType paramType = (ParameterizedType)fieldType;
Type[] types2 = paramType.getActualTypeArguments();
if(types2.length != 1)
throw new JsonException("not support the " + field);
Type elementType = types2[0];
parserMetaInfo.setType(ComplexTypeParser.getImplClass(type));
parserMetaInfo.setParser(new CollectionParser(elementType));
} else if (Map.class.isAssignableFrom(type)) { // Map元信息构造
Type fieldType = field.getGenericType();
if(!(fieldType instanceof ParameterizedType))
throw new JsonException("not support the " + field);
ParameterizedType paramType = (ParameterizedType) fieldType;
Type[] types2 = paramType.getActualTypeArguments();
if(types2.length != 2)
throw new JsonException("not support the " + field);
Type key = types2[0];
if (!((key instanceof Class) && key == String.class))
throw new JsonException("not support the " + field);
Type elementType = types2[1];
parserMetaInfo.setType(ComplexTypeParser.getImplClass(type));
parserMetaInfo.setParser(new MapParser(elementType));
} else { // 获取对象、枚举或者数组Parser
parserMetaInfo.setType(type);
parserMetaInfo.setParser(ParserStateMachine.getParser(type));
}
fieldSet.add(parserMetaInfo);