if (field != null
&& (Modifier.isTransient(field.getModifiers())
|| field.isAnnotationPresent(Transient.class)))
continue;
ParserMetaInfo parserMetaInfo = new ParserMetaInfo();
parserMetaInfo.setPropertyNameString(propertyName);
parserMetaInfo.setPropertyInvoke(new MethodInvoke(method));
Class<?> type = method.getParameterTypes()[0];
if (Collection.class.isAssignableFrom(type)) {
Type[] types = method.getGenericParameterTypes();
if(types.length != 1 || !(types[0] instanceof ParameterizedType))
throw new JsonException("not support the " + method);
ParameterizedType paramType = (ParameterizedType) types[0];
Type[] types2 = paramType.getActualTypeArguments();
if(types2.length != 1)
throw new JsonException("not support the " + method);
Type elementType = types2[0];
parserMetaInfo.setType(ComplexTypeParser.getImplClass(type));
parserMetaInfo.setParser(new CollectionParser(elementType));
} else if (Map.class.isAssignableFrom(type)) { // Map元信息构造
Type[] types = method.getGenericParameterTypes();
if(types.length != 1 || !(types[0] instanceof ParameterizedType))
throw new JsonException("not support the " + method);
ParameterizedType paramType = (ParameterizedType) types[0];
Type[] types2 = paramType.getActualTypeArguments();
if(types2.length != 2)
throw new JsonException("not support the " + method);
Type key = types2[0];
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);
}
parserMetaInfos = fieldSet.toArray(EMPTY_ARRAY);