下面列出了com.fasterxml.jackson.databind.DeserializationContext#getContextualType ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
BeanProperty property) {
JavaType contextualType = ctxt.getContextualType();
checkArgument(contextualType.isEnumType());
return createFromType(contextualType);
}
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
BeanProperty property) {
JavaType contextualType = ctxt.getContextualType();
checkArgument(contextualType.isEnumType());
return createFromType(contextualType);
}
@Override
public JsonDeserializer<?> createContextual(DeserializationContext deserializationContext, BeanProperty beanProperty) {
JavaType javaType = deserializationContext.getContextualType() != null ? deserializationContext.getContextualType() : extractType(beanProperty.getMember());
Annotation[] annotations = annotations(beanProperty);
AnnotatedType detectedType = environment.typeTransformer.transform(ClassUtils.addAnnotations(TypeUtils.toJavaType(javaType), annotations));
JavaType substituteType = deserializationContext.getTypeFactory().constructType(environment.getMappableInputType(detectedType).getType());
if (inputConverter.supports(detectedType)) {
return new ConvertingDeserializer(detectedType, substituteType, inputConverter, environment, objectMapper);
} else {
return new DefaultDeserializer(javaType);
}
}
@Override
public JsonDeserializer<?> createContextual( DeserializationContext ctxt, BeanProperty property ) throws JsonMappingException {
if ( ctxt.getContextualType() == null || ctxt.getContextualType().containedType( 0 ) == null ) {
throw JsonMappingException.from( ctxt, "Cannot deserialize Ref<T>. Cannot find the Generic Type T." );
}
return new RefStdDeserializer( ctxt.getContextualType().containedType( 0 ) );
}
@Override
public KeyDeserializer createContextual( DeserializationContext ctxt, BeanProperty property ) throws JsonMappingException {
if ( ctxt.getContextualType() == null || ctxt.getContextualType().containedType( 0 ) == null || ctxt.getContextualType().containedType( 0 ).containedType( 0 ) == null ) {
throw JsonMappingException.from( ctxt, "Cannot deserialize Ref<T>. Cannot find the Generic Type T." );
}
return new RefStdKeyDeserializer( ctxt.getContextualType().containedType( 0 ).containedType( 0 ) );
}
@Override
public JsonDeserializer<?> createContextual(
final DeserializationContext deserializationContext, final BeanProperty beanProperty)
throws JsonMappingException {
return new TableDeserializer(deserializationContext.getContextualType());
}