当前位置: 首页>>代码示例>>Java>>正文


Java TypeResolverBuilder.buildTypeDeserializer方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder.buildTypeDeserializer方法的典型用法代码示例。如果您正苦于以下问题:Java TypeResolverBuilder.buildTypeDeserializer方法的具体用法?Java TypeResolverBuilder.buildTypeDeserializer怎么用?Java TypeResolverBuilder.buildTypeDeserializer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder的用法示例。


在下文中一共展示了TypeResolverBuilder.buildTypeDeserializer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findPropertyTypeDeserializer

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入方法依赖的package包/类
/**
 * Method called to create a type information deserializer for values of
 * given non-container property, if one is needed.
 * If not needed (no polymorphic handling configured for property), should return null.
 *<p>
 * Note that this method is only called for non-container bean properties,
 * and not for values in container types or root values (or container properties)
 *
 * @param baseType Declared base type of the value to deserializer (actual
 *    deserializer type will be this type or its subtype)
 * 
 * @return Type deserializer to use for given base type, if one is needed; null if not.
 */
public TypeDeserializer findPropertyTypeDeserializer(DeserializationConfig config,
        JavaType baseType, AnnotatedMember annotated)
    throws JsonMappingException
{
    AnnotationIntrospector ai = config.getAnnotationIntrospector();
    TypeResolverBuilder<?> b = ai.findPropertyTypeResolver(config, annotated, baseType);        
    // Defaulting: if no annotations on member, check value class
    if (b == null) {
        return findTypeDeserializer(config, baseType);
    }
    // but if annotations found, may need to resolve subtypes:
    Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypes(
            annotated, config, ai, baseType);
    return b.buildTypeDeserializer(config, baseType, subtypes);
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:29,代码来源:BasicDeserializerFactory.java

示例2: findPropertyContentTypeDeserializer

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入方法依赖的package包/类
/**
 * Method called to find and create a type information deserializer for values of
 * given container (list, array, map) property, if one is needed.
 * If not needed (no polymorphic handling configured for property), should return null.
 *<p>
 * Note that this method is only called for container bean properties,
 * and not for values in container types or root values (or non-container properties)
 * 
 * @param containerType Type of property; must be a container type
 * @param propertyEntity Field or method that contains container property
 */    
public TypeDeserializer findPropertyContentTypeDeserializer(DeserializationConfig config,
        JavaType containerType, AnnotatedMember propertyEntity)
    throws JsonMappingException
{
    AnnotationIntrospector ai = config.getAnnotationIntrospector();
    TypeResolverBuilder<?> b = ai.findPropertyContentTypeResolver(config, propertyEntity, containerType);        
    JavaType contentType = containerType.getContentType();
    // Defaulting: if no annotations on member, check class
    if (b == null) {
        return findTypeDeserializer(config, contentType);
    }
    // but if annotations found, may need to resolve subtypes:
    Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypes(
            propertyEntity, config, ai, contentType);
    return b.buildTypeDeserializer(config, contentType, subtypes);
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:28,代码来源:BasicDeserializerFactory.java

示例3: getObjectMapper

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入方法依赖的package包/类
private ObjectMapper getObjectMapper() {
    objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
    // objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS,
    // true);
    objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);

    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    TypeResolverBuilder<?> joynrTypeResolverBuilder = objectMapper.getSerializationConfig()
                                                                  .getDefaultTyper(SimpleType.construct(Object.class));

    SimpleModule module = new SimpleModule("NonTypedModule", new Version(1, 0, 0, "", "", ""));
    module.addSerializer(new JoynrEnumSerializer());
    module.addSerializer(new JoynrListSerializer());

    TypeDeserializer typeDeserializer = joynrTypeResolverBuilder.buildTypeDeserializer(objectMapper.getDeserializationConfig(),
                                                                                       SimpleType.construct(Object.class),
                                                                                       null);

    module.addDeserializer(Object.class, new JoynrUntypedObjectDeserializer(typeDeserializer));
    objectMapper.registerModule(module);
    return objectMapper;
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:27,代码来源:AbstractBounceProxyServerTest.java

示例4: findPropertyContentTypeDeserializer

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入方法依赖的package包/类
public TypeDeserializer findPropertyContentTypeDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, AnnotatedMember paramAnnotatedMember)
{
  AnnotationIntrospector localAnnotationIntrospector = paramDeserializationConfig.getAnnotationIntrospector();
  TypeResolverBuilder localTypeResolverBuilder = localAnnotationIntrospector.findPropertyContentTypeResolver(paramDeserializationConfig, paramAnnotatedMember, paramJavaType);
  JavaType localJavaType = paramJavaType.getContentType();
  if (localTypeResolverBuilder == null)
    return findTypeDeserializer(paramDeserializationConfig, localJavaType);
  return localTypeResolverBuilder.buildTypeDeserializer(paramDeserializationConfig, localJavaType, paramDeserializationConfig.getSubtypeResolver().collectAndResolveSubtypes(paramAnnotatedMember, paramDeserializationConfig, localAnnotationIntrospector, localJavaType));
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:10,代码来源:BasicDeserializerFactory.java

示例5: findPropertyTypeDeserializer

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入方法依赖的package包/类
public TypeDeserializer findPropertyTypeDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, AnnotatedMember paramAnnotatedMember)
{
  AnnotationIntrospector localAnnotationIntrospector = paramDeserializationConfig.getAnnotationIntrospector();
  TypeResolverBuilder localTypeResolverBuilder = localAnnotationIntrospector.findPropertyTypeResolver(paramDeserializationConfig, paramAnnotatedMember, paramJavaType);
  if (localTypeResolverBuilder == null)
    return findTypeDeserializer(paramDeserializationConfig, paramJavaType);
  return localTypeResolverBuilder.buildTypeDeserializer(paramDeserializationConfig, paramJavaType, paramDeserializationConfig.getSubtypeResolver().collectAndResolveSubtypes(paramAnnotatedMember, paramDeserializationConfig, localAnnotationIntrospector, paramJavaType));
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:9,代码来源:BasicDeserializerFactory.java

示例6: findTypeDeserializer

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入方法依赖的package包/类
@Override
public TypeDeserializer findTypeDeserializer(DeserializationConfig config,
        JavaType baseType)
    throws JsonMappingException
{
    Class<?> cls = baseType.getRawClass();
    BeanDescription bean = config.introspectClassAnnotations(cls);
    AnnotatedClass ac = bean.getClassInfo();
    AnnotationIntrospector ai = config.getAnnotationIntrospector();
    TypeResolverBuilder<?> b = ai.findTypeResolver(config, ac, baseType);

    /* Ok: if there is no explicit type info handler, we may want to
     * use a default. If so, config object knows what to use.
     */
    Collection<NamedType> subtypes = null;
    if (b == null) {
        b = config.getDefaultTyper(baseType);
        if (b == null) {
            return null;
        }
    } else {
        subtypes = config.getSubtypeResolver().collectAndResolveSubtypes(ac, config, ai);
    }
    // [JACKSON-505]: May need to figure out default implementation, if none found yet
    // (note: check for abstract type is not 100% mandatory, more of an optimization)
    if ((b.getDefaultImpl() == null) && baseType.isAbstract()) {
        JavaType defaultType = mapAbstractType(config, baseType);
        if (defaultType != null && defaultType.getRawClass() != baseType.getRawClass()) {
            b = b.defaultImpl(defaultType.getRawClass());
        }
    }
    return b.buildTypeDeserializer(config, baseType, subtypes);
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:34,代码来源:BasicDeserializerFactory.java

示例7: JsonMessageSerializerModule

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入方法依赖的package包/类
public JsonMessageSerializerModule() {
    objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
    objectMapper.configure(DeserializationFeature.USE_JAVA_ARRAY_FOR_JSON_ARRAY, true);
    // objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
    objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);

    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    TypeResolverBuilder<?> joynrTypeResolverBuilder = objectMapper.getSerializationConfig()
                                                                  .getDefaultTyper(SimpleType.construct(Object.class));

    SimpleModule module = new SimpleModule("NonTypedModule", new Version(1, 0, 0, "", "", ""));
    module.addSerializer(new JoynrEnumSerializer());
    module.addSerializer(new JoynrListSerializer());
    module.addSerializer(new JoynrArraySerializer());

    TypeDeserializer typeDeserializer = joynrTypeResolverBuilder.buildTypeDeserializer(objectMapper.getDeserializationConfig(),
                                                                                       SimpleType.construct(Object.class),
                                                                                       null);

    module.addDeserializer(Request.class, new RequestDeserializer(objectMapper));
    module.addDeserializer(OneWayRequest.class, new OneWayRequestDeserializer(objectMapper));
    module.addDeserializer(Object.class, new JoynrUntypedObjectDeserializer(typeDeserializer));

    module.setMixInAnnotation(Throwable.class, ThrowableMixIn.class);
    objectMapper.registerModule(module);
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:31,代码来源:JsonMessageSerializerModule.java


注:本文中的com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder.buildTypeDeserializer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。