cn.featherfly.conversion.parse.JacksonParser Maven / Gradle / Ivy
package cn.featherfly.conversion.parse;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import com.fasterxml.jackson.databind.ObjectMapper;
import cn.featherfly.common.lang.GenericType;
/**
*
* 使用jackson解析协议的解析器抽象类
*
*
* @param 解析的目标类型描述
* @author 钟冀
*/
public abstract class JacksonParser> extends AbstractParser {
/**
* objectMapper
*/
protected ObjectMapper objectMapper;
/**
*/
public JacksonParser(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
/**
*
* 创建ParameterizedType
*
*
* @param rawType rawType
* @param ownerType ownerType
* @param ctualTypeArguments ctualTypeArguments
* @return ParameterizedType
*/
protected ParameterizedType createParameterizedType(final Type rawType, final Type ownerType,
final Type... ctualTypeArguments) {
return new ParameterizedType() {
@Override
public Type[] getActualTypeArguments() {
return ctualTypeArguments;
}
@Override
public Type getRawType() {
return rawType;
}
@Override
public Type getOwnerType() {
return ownerType;
}
};
}
/**
*
* 返回正文对象
*
*
* @param content 正文
* @return Content对象
*/
protected abstract Content getContent(String content);
/**
*
* 内部解析使用对象Content
*
*
* @author 钟冀
*/
protected static final class Content {
/***/
protected Content() {
}
/**
* className
*/
protected String className;
/**
* jsonContent
*/
protected String content;
/**
* isMulty
*/
protected boolean isMulty;
}
}