下面列出了com.fasterxml.jackson.databind.introspect.Annotated#getType ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public Object findDeserializationConverter(Annotated a) {
JtToMap ann = a.getAnnotation(JtToMap.class);
if (ann == null) {
return null;
}
JavaType javaType = a.getType();
if(a instanceof AnnotatedMethod) {
AnnotatedMethod am = (AnnotatedMethod) a;
if(am.getParameterCount() == 1) {
javaType = am.getParameterType(0);
} else {
throw new RuntimeException("Invalid property setter: " + am.getAnnotated());
}
}
return new DeserializationConverterImpl(ann, new Ctx(a, javaType));
}
@Override
public Object findDeserializationConverter(Annotated a) {
Class<? extends PropertyInterceptor>[] interceptors = getInterceptors(a);
if (interceptors == null) {
return null;
}
JavaType javaType = a.getType();
if(a instanceof AnnotatedMethod) {
AnnotatedMethod am = (AnnotatedMethod) a;
if(am.getParameterCount() == 1) {
javaType = am.getParameterType(0);
} else {
throw new RuntimeException("Invalid property setter: " + am.getAnnotated());
}
}
return new KvInterceptorsDeserializationConverter(interceptors, new KvPropertyContextImpl(a, javaType));
}
private JavaType extractType(Annotated annotated) {
if (annotated instanceof AnnotatedMethod) {
AnnotatedMethod method = (AnnotatedMethod) annotated;
if (ClassUtils.isSetter(method.getAnnotated())) {
return method.getParameterType(0);
}
return method.getType();
}
return annotated.getType();
}
@Override
public Object findSerializationConverter(Annotated a) {
JtToMap ann = a.getAnnotation(JtToMap.class);
if (ann == null) {
return null;
}
return new SerializationConverterImpl(ann, new Ctx(a, a.getType()));
}
@Override
public Object findSerializationConverter(Annotated a) {
Class<? extends PropertyInterceptor>[] interceptors = getInterceptors(a);
if (interceptors == null) {
return null;
}
return new KvInterceptorsSerializationConverter(interceptors, new KvPropertyContextImpl(a, a.getType()));
}
private Type getType(Annotated a) {
try {
// Jackson 2.7+
return a.getType();
} catch (Throwable t) {
return a.getGenericType();
}
}