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


Java TypeResolverBuilder类代码示例

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


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

示例1: getObjectMapper

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入依赖的package包/类
@Bean(name = "objectMapper")
public ObjectMapper getObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();

    mapper.registerModule(new GuavaModule());
    mapper.registerModule(new Jdk8Module());
    mapper.registerModule(new JodaModule());
    mapper.setAnnotationIntrospector(new JacksonAnnotationIntrospector() {
        // borrowed from: http://jackson-users.ning.com/forum/topics/how-to-not-include-type-info-during-serialization-with
        @Override
        protected TypeResolverBuilder<?> _findTypeResolver(MapperConfig<?> config, Annotated ann, JavaType baseType) {

            // Don't serialize JsonTypeInfo Property includes
            if (ann.hasAnnotation(JsonTypeInfo.class)
                    && ann.getAnnotation(JsonTypeInfo.class).include() == JsonTypeInfo.As.PROPERTY
                    && SerializationConfig.class.isAssignableFrom(config.getClass())) {
                return null;

            }

            return super._findTypeResolver(config, ann, baseType);
        }
    });

    return mapper;
}
 
开发者ID:bpatters,项目名称:eservice,代码行数:27,代码来源:CommonBeans.java

示例2: configureObjectMapper

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入依赖的package包/类
/**
 * Configure an existing object mapper to work with Archie RM and AOM Objects.
 * Indentation is enabled. Feel free to disable again in your own code.
 * @param objectMapper
 */
public static void configureObjectMapper(ObjectMapper objectMapper) {
    objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
    objectMapper.enable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE);
    objectMapper.disable(SerializationFeature.WRITE_NULL_MAP_VALUES);
    objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
    objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
    objectMapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
    objectMapper.enable(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS);
    objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    //objectMapper.

    objectMapper.registerModule(new JavaTimeModule());


    TypeResolverBuilder typeResolverBuilder = new ArchieTypeResolverBuilder()
            .init(JsonTypeInfo.Id.NAME, new OpenEHRTypeNaming())
            .typeProperty("@type")
            .typeIdVisibility(true)
            .inclusion(JsonTypeInfo.As.PROPERTY);

    objectMapper.setDefaultTyping(typeResolverBuilder);
}
 
开发者ID:nedap,项目名称:archie,代码行数:30,代码来源:JacksonUtil.java

示例3: createTypeSerializer

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入依赖的package包/类
public TypeSerializer createTypeSerializer(SerializationConfig paramSerializationConfig, JavaType paramJavaType)
{
  AnnotatedClass localAnnotatedClass = paramSerializationConfig.introspectClassAnnotations(paramJavaType.getRawClass()).getClassInfo();
  AnnotationIntrospector localAnnotationIntrospector = paramSerializationConfig.getAnnotationIntrospector();
  TypeResolverBuilder localTypeResolverBuilder = localAnnotationIntrospector.findTypeResolver(paramSerializationConfig, localAnnotatedClass, paramJavaType);
  Collection localCollection;
  if (localTypeResolverBuilder == null)
  {
    localTypeResolverBuilder = paramSerializationConfig.getDefaultTyper(paramJavaType);
    localCollection = null;
  }
  else
  {
    localCollection = paramSerializationConfig.getSubtypeResolver().collectAndResolveSubtypes(localAnnotatedClass, paramSerializationConfig, localAnnotationIntrospector);
  }
  if (localTypeResolverBuilder == null)
    return null;
  return localTypeResolverBuilder.buildTypeSerializer(paramSerializationConfig, paramJavaType, localCollection);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:20,代码来源:BasicSerializerFactory.java

示例4: findTypeDeserializer

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入依赖的package包/类
public TypeDeserializer findTypeDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType)
{
  AnnotatedClass localAnnotatedClass = paramDeserializationConfig.introspectClassAnnotations(paramJavaType.getRawClass()).getClassInfo();
  AnnotationIntrospector localAnnotationIntrospector = paramDeserializationConfig.getAnnotationIntrospector();
  Object localObject = localAnnotationIntrospector.findTypeResolver(paramDeserializationConfig, localAnnotatedClass, paramJavaType);
  Collection localCollection;
  if (localObject == null)
  {
    TypeResolverBuilder localTypeResolverBuilder = paramDeserializationConfig.getDefaultTyper(paramJavaType);
    localObject = localTypeResolverBuilder;
    localCollection = null;
    if (localTypeResolverBuilder == null)
      return null;
  }
  else
  {
    localCollection = paramDeserializationConfig.getSubtypeResolver().collectAndResolveSubtypes(localAnnotatedClass, paramDeserializationConfig, localAnnotationIntrospector);
  }
  if ((((TypeResolverBuilder)localObject).getDefaultImpl() == null) && (paramJavaType.isAbstract()))
  {
    JavaType localJavaType = mapAbstractType(paramDeserializationConfig, paramJavaType);
    if ((localJavaType != null) && (localJavaType.getRawClass() != paramJavaType.getRawClass()))
      localObject = ((TypeResolverBuilder)localObject).defaultImpl(localJavaType.getRawClass());
  }
  return ((TypeResolverBuilder)localObject).buildTypeDeserializer(paramDeserializationConfig, paramJavaType, localCollection);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:27,代码来源:BasicDeserializerFactory.java

示例5: BaseSettings

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入依赖的package包/类
public BaseSettings(ClassIntrospector ci, AnnotationIntrospector ai,
        VisibilityChecker<?> vc, PropertyNamingStrategy pns, TypeFactory tf,
        TypeResolverBuilder<?> typer, DateFormat dateFormat, HandlerInstantiator hi,
        Locale locale, TimeZone tz, Base64Variant defaultBase64)
{
    _classIntrospector = ci;
    _annotationIntrospector = ai;
    _visibilityChecker = vc;
    _propertyNamingStrategy = pns;
    _typeFactory = tf;
    _typeResolverBuilder = typer;
    _dateFormat = dateFormat;
    _handlerInstantiator = hi;
    _locale = locale;
    _timeZone = tz;
    _defaultBase64 = defaultBase64;
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:18,代码来源:BaseSettings.java

示例6: findPropertyContentTypeSerializer

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入依赖的package包/类
/**
 * Method called to create a type information serializer for values of given
 * container property
 * if one is needed. If not needed (no polymorphic handling configured), should
 * return null.
 *
 * @param containerType Declared type of the container to use as the base type for type information serializer
 * 
 * @return Type serializer to use for property value contents, if one is needed; null if not.
 */    
public TypeSerializer findPropertyContentTypeSerializer(JavaType containerType,
        SerializationConfig config, AnnotatedMember accessor)
    throws JsonMappingException
{
    JavaType contentType = containerType.getContentType();
    AnnotationIntrospector ai = config.getAnnotationIntrospector();
    TypeResolverBuilder<?> b = ai.findPropertyContentTypeResolver(config, accessor, containerType);        
    // Defaulting: if no annotations on member, check value class
    if (b == null) {
        return createTypeSerializer(config, contentType);
    }
    Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypes(accessor,
            config, ai, contentType);
    return b.buildTypeSerializer(config, contentType, subtypes);
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:26,代码来源:BeanSerializerFactory.java

示例7: createTypeSerializer

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入依赖的package包/类
/**
 * Method called to construct a type serializer for values with given declared
 * base type. This is called for values other than those of bean property
 * types.
 */
@Override
public TypeSerializer createTypeSerializer(SerializationConfig config,
        JavaType baseType)
{
    BeanDescription bean = config.introspectClassAnnotations(baseType.getRawClass());
    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);
    } else {
        subtypes = config.getSubtypeResolver().collectAndResolveSubtypes(ac, config, ai);
    }
    if (b == null) {
        return null;
    }
    return b.buildTypeSerializer(config, baseType, subtypes);
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:28,代码来源:BasicSerializerFactory.java

示例8: 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

示例9: 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

示例10: 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

示例11: 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));

    return objectMapper;
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:17,代码来源:MessagingTest.java

示例12: JsonJacksonCodec

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入依赖的package包/类
public JsonJacksonCodec() {
    init(mapObjectMapper);
    // type info inclusion
    TypeResolverBuilder<?> mapTyper = new DefaultTypeResolverBuilder(DefaultTyping.NON_FINAL) {
        public boolean useForType(JavaType t)
        {
            switch (_appliesFor) {
            case NON_CONCRETE_AND_ARRAYS:
                while (t.isArrayType()) {
                    t = t.getContentType();
                }
                // fall through
            case OBJECT_AND_NON_CONCRETE:
                return (t.getRawClass() == Object.class) || !t.isConcrete();
            case NON_FINAL:
                while (t.isArrayType()) {
                    t = t.getContentType();
                }
                // to fix problem with wrong long to int conversion
                if (t.getRawClass() == Long.class) {
                    return true;
                }
                return !t.isFinal(); // includes Object.class
            default:
            //case JAVA_LANG_OBJECT:
                return (t.getRawClass() == Object.class);
            }
        }
    };
    mapTyper.init(JsonTypeInfo.Id.CLASS, null);
    mapTyper.inclusion(JsonTypeInfo.As.PROPERTY);
    mapObjectMapper.setDefaultTyping(mapTyper);
}
 
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:34,代码来源:JsonJacksonCodec.java

示例13: typeResolverBuilderInstance

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入依赖的package包/类
@Override
public TypeResolverBuilder<?> typeResolverBuilderInstance(
		MapperConfig<?> mapperConfig, Annotated annotated,
		Class<?>
		typeResolverBuilderClass) {
	return null;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:8,代码来源:CustomHandlerInstantiator.java

示例14: BaseSettings

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入依赖的package包/类
public BaseSettings(ClassIntrospector paramClassIntrospector, AnnotationIntrospector paramAnnotationIntrospector, VisibilityChecker<?> paramVisibilityChecker, PropertyNamingStrategy paramPropertyNamingStrategy, TypeFactory paramTypeFactory, TypeResolverBuilder<?> paramTypeResolverBuilder, DateFormat paramDateFormat, HandlerInstantiator paramHandlerInstantiator, Locale paramLocale, TimeZone paramTimeZone, Base64Variant paramBase64Variant)
{
  this._classIntrospector = paramClassIntrospector;
  this._annotationIntrospector = paramAnnotationIntrospector;
  this._visibilityChecker = paramVisibilityChecker;
  this._propertyNamingStrategy = paramPropertyNamingStrategy;
  this._typeFactory = paramTypeFactory;
  this._typeResolverBuilder = paramTypeResolverBuilder;
  this._dateFormat = paramDateFormat;
  this._handlerInstantiator = paramHandlerInstantiator;
  this._locale = paramLocale;
  this._timeZone = paramTimeZone;
  this._defaultBase64 = paramBase64Variant;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:15,代码来源:BaseSettings.java

示例15: with

import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; //导入依赖的package包/类
public final BaseSettings with(TimeZone paramTimeZone)
{
  if (paramTimeZone == null)
    throw new IllegalArgumentException();
  DateFormat localDateFormat1 = this._dateFormat;
  Object localObject;
  if ((localDateFormat1 instanceof StdDateFormat))
  {
    localObject = ((StdDateFormat)localDateFormat1).withTimeZone(paramTimeZone);
  }
  else
  {
    DateFormat localDateFormat2 = (DateFormat)localDateFormat1.clone();
    localObject = localDateFormat2;
    localDateFormat2.setTimeZone(paramTimeZone);
  }
  ClassIntrospector localClassIntrospector = this._classIntrospector;
  AnnotationIntrospector localAnnotationIntrospector = this._annotationIntrospector;
  VisibilityChecker localVisibilityChecker = this._visibilityChecker;
  PropertyNamingStrategy localPropertyNamingStrategy = this._propertyNamingStrategy;
  TypeFactory localTypeFactory = this._typeFactory;
  TypeResolverBuilder localTypeResolverBuilder = this._typeResolverBuilder;
  HandlerInstantiator localHandlerInstantiator = this._handlerInstantiator;
  Locale localLocale = this._locale;
  Base64Variant localBase64Variant = this._defaultBase64;
  return new BaseSettings(localClassIntrospector, localAnnotationIntrospector, localVisibilityChecker, localPropertyNamingStrategy, localTypeFactory, localTypeResolverBuilder, (DateFormat)localObject, localHandlerInstantiator, localLocale, paramTimeZone, localBase64Variant);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:28,代码来源:BaseSettings.java


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