package org.nybatis.core.reflection.deserializer;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.deser.ContextualDeserializer;
import org.nybatis.core.reflection.Reflector;

import java.io.IOException;

public class ColumnBeanDeserializer extends JsonDeserializer<Object> implements ContextualDeserializer {

	private JavaType javaType;

	@Override
	public Object deserialize( JsonParser p, DeserializationContext ctxt ) throws IOException {
		ObjectMapper objectMapper = Reflector.jsonConverter.getObjectMapper();
		String json = p.getValueAsString();
		if( json == null ) {
			return objectMapper.readValue( p, javaType );
		} else {
			return objectMapper.readValue( json, javaType );
		}
	}

	private ObjectMapper getObjectMapper( JsonParser p ) {
		return (ObjectMapper) p.getCodec();
	}

	@Override
	public JsonDeserializer<?> createContextual( DeserializationContext ctxt, BeanProperty property ) throws JsonMappingException {
		javaType = property.getType();
		return this;
	}

}

@@ -94,67 +94,8 @@
 er;%0A
-import com.fasterxml.jackson.core.JsonProcessingException;%0A
 impo
@@ -772,106 +772,8 @@
 %09%7D%0A%0A
-%09private ObjectMapper getObjectMapper( JsonParser p ) %7B%0A%09%09return (ObjectMapper) p.getCodec();%0A%09%7D%0A%0A
 %09@Ov

remove unused code