Package com.firefly.utils.json.parser

Examples of com.firefly.utils.json.parser.MapParser


              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);
View Full Code Here

TOP

Related Classes of com.firefly.utils.json.parser.MapParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.