All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gu.dtalk.ItemDeserializer Maven / Gradle / Ivy

There is a newer version: 0.8.2
Show newest version
package gu.dtalk;

import java.lang.reflect.Type;
import java.util.Map;

import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer;
import com.alibaba.fastjson.parser.deserializer.MapDeserializer;

/**
 * item对象反序列化实现
 * @author guyadong
 *
 */
public class ItemDeserializer extends JavaBeanDeserializer{
	public static final ItemDeserializer instance = new ItemDeserializer();
	public ItemDeserializer() {
		super(ParserConfig.global, BaseItem.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	public  T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
		Map map = MapDeserializer.instance.deserialze(parser, 
				new TypeReference>(){}.getType(), fieldName);
		return (T) createInstance(map,null);
	}

	@Override
	public Object createInstance(Map map, ParserConfig config) {
		return ItemType.parseItem(map);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy