Java 类com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder 实例源码

项目:eservice    文件:CommonBeans.java   
@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;
}
项目:archie    文件:JacksonUtil.java   
/**
 * 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);
}
项目:QuizUpWinner    文件:BasicSerializerFactory.java   
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);
}
项目:QuizUpWinner    文件:BasicDeserializerFactory.java   
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);
}
项目:joyplus-tv    文件:BaseSettings.java   
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;
}
项目:joyplus-tv    文件:BeanSerializerFactory.java   
/**
 * 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);
}
项目:joyplus-tv    文件:BasicSerializerFactory.java   
/**
 * 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);
}
项目:joyplus-tv    文件:BasicDeserializerFactory.java   
/**
 * 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);
}
项目:joyplus-tv    文件:BasicDeserializerFactory.java   
/**
 * 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);
}
项目:joynr    文件:AbstractBounceProxyServerTest.java   
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;
}
项目:joynr    文件:MessagingTest.java   
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;
}
项目:redisson    文件:JsonJacksonCodec.java   
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);
}
项目:eMonocot    文件:CustomHandlerInstantiator.java   
@Override
public TypeResolverBuilder<?> typeResolverBuilderInstance(
        MapperConfig<?> mapperConfig, Annotated annotated,
        Class<?>
        typeResolverBuilderClass) {
    return null;
}
项目:powop    文件:CustomHandlerInstantiator.java   
@Override
public TypeResolverBuilder<?> typeResolverBuilderInstance(
        MapperConfig<?> mapperConfig, Annotated annotated,
        Class<?>
        typeResolverBuilderClass) {
    return null;
}
项目:QuizUpWinner    文件:BaseSettings.java   
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;
}
项目:QuizUpWinner    文件:BaseSettings.java   
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);
}
项目:QuizUpWinner    文件:MapperConfig.java   
public TypeResolverBuilder<?> typeResolverBuilderInstance(Annotated paramAnnotated, Class<? extends TypeResolverBuilder<?>> paramClass)
{
  HandlerInstantiator localHandlerInstantiator = getHandlerInstantiator();
  if (localHandlerInstantiator != null)
  {
    TypeResolverBuilder localTypeResolverBuilder = localHandlerInstantiator.typeResolverBuilderInstance(this, paramAnnotated, paramClass);
    if (localTypeResolverBuilder != null)
      return localTypeResolverBuilder;
  }
  return (TypeResolverBuilder)ClassUtil.createInstance(paramClass, canOverrideAccessModifiers());
}
项目:QuizUpWinner    文件:BeanSerializerFactory.java   
public TypeSerializer findPropertyContentTypeSerializer(JavaType paramJavaType, SerializationConfig paramSerializationConfig, AnnotatedMember paramAnnotatedMember)
{
  JavaType localJavaType = paramJavaType.getContentType();
  AnnotationIntrospector localAnnotationIntrospector = paramSerializationConfig.getAnnotationIntrospector();
  TypeResolverBuilder localTypeResolverBuilder = localAnnotationIntrospector.findPropertyContentTypeResolver(paramSerializationConfig, paramAnnotatedMember, paramJavaType);
  if (localTypeResolverBuilder == null)
    return createTypeSerializer(paramSerializationConfig, localJavaType);
  return localTypeResolverBuilder.buildTypeSerializer(paramSerializationConfig, localJavaType, paramSerializationConfig.getSubtypeResolver().collectAndResolveSubtypes(paramAnnotatedMember, paramSerializationConfig, localAnnotationIntrospector, localJavaType));
}
项目:QuizUpWinner    文件:BeanSerializerFactory.java   
public TypeSerializer findPropertyTypeSerializer(JavaType paramJavaType, SerializationConfig paramSerializationConfig, AnnotatedMember paramAnnotatedMember)
{
  AnnotationIntrospector localAnnotationIntrospector = paramSerializationConfig.getAnnotationIntrospector();
  TypeResolverBuilder localTypeResolverBuilder = localAnnotationIntrospector.findPropertyTypeResolver(paramSerializationConfig, paramAnnotatedMember, paramJavaType);
  if (localTypeResolverBuilder == null)
    return createTypeSerializer(paramSerializationConfig, paramJavaType);
  return localTypeResolverBuilder.buildTypeSerializer(paramSerializationConfig, paramJavaType, paramSerializationConfig.getSubtypeResolver().collectAndResolveSubtypes(paramAnnotatedMember, paramSerializationConfig, localAnnotationIntrospector, paramJavaType));
}
项目:QuizUpWinner    文件:AnnotationIntrospectorPair.java   
public TypeResolverBuilder<?> findPropertyContentTypeResolver(MapperConfig<?> paramMapperConfig, AnnotatedMember paramAnnotatedMember, JavaType paramJavaType)
{
  TypeResolverBuilder localTypeResolverBuilder1 = this._primary.findPropertyContentTypeResolver(paramMapperConfig, paramAnnotatedMember, paramJavaType);
  TypeResolverBuilder localTypeResolverBuilder2 = localTypeResolverBuilder1;
  if (localTypeResolverBuilder1 == null)
    localTypeResolverBuilder2 = this._secondary.findPropertyContentTypeResolver(paramMapperConfig, paramAnnotatedMember, paramJavaType);
  return localTypeResolverBuilder2;
}
项目:QuizUpWinner    文件:AnnotationIntrospectorPair.java   
public TypeResolverBuilder<?> findPropertyTypeResolver(MapperConfig<?> paramMapperConfig, AnnotatedMember paramAnnotatedMember, JavaType paramJavaType)
{
  TypeResolverBuilder localTypeResolverBuilder1 = this._primary.findPropertyTypeResolver(paramMapperConfig, paramAnnotatedMember, paramJavaType);
  TypeResolverBuilder localTypeResolverBuilder2 = localTypeResolverBuilder1;
  if (localTypeResolverBuilder1 == null)
    localTypeResolverBuilder2 = this._secondary.findPropertyTypeResolver(paramMapperConfig, paramAnnotatedMember, paramJavaType);
  return localTypeResolverBuilder2;
}
项目:QuizUpWinner    文件:AnnotationIntrospectorPair.java   
public TypeResolverBuilder<?> findTypeResolver(MapperConfig<?> paramMapperConfig, AnnotatedClass paramAnnotatedClass, JavaType paramJavaType)
{
  TypeResolverBuilder localTypeResolverBuilder1 = this._primary.findTypeResolver(paramMapperConfig, paramAnnotatedClass, paramJavaType);
  TypeResolverBuilder localTypeResolverBuilder2 = localTypeResolverBuilder1;
  if (localTypeResolverBuilder1 == null)
    localTypeResolverBuilder2 = this._secondary.findTypeResolver(paramMapperConfig, paramAnnotatedClass, paramJavaType);
  return localTypeResolverBuilder2;
}
项目:QuizUpWinner    文件:JacksonAnnotationIntrospector.java   
protected TypeResolverBuilder<?> _findTypeResolver(MapperConfig<?> paramMapperConfig, Annotated paramAnnotated, JavaType paramJavaType)
{
  JsonTypeInfo localJsonTypeInfo = (JsonTypeInfo)paramAnnotated.getAnnotation(JsonTypeInfo.class);
  JsonTypeResolver localJsonTypeResolver = (JsonTypeResolver)paramAnnotated.getAnnotation(JsonTypeResolver.class);
  Object localObject;
  if (localJsonTypeResolver != null)
  {
    if (localJsonTypeInfo == null)
      return null;
    localObject = paramMapperConfig.typeResolverBuilderInstance(paramAnnotated, localJsonTypeResolver.value());
  }
  else
  {
    if (localJsonTypeInfo == null)
      return null;
    if (localJsonTypeInfo.use() == JsonTypeInfo.Id.NONE)
      return _constructNoTypeResolverBuilder();
    localObject = _constructStdTypeResolverBuilder();
  }
  JsonTypeIdResolver localJsonTypeIdResolver = (JsonTypeIdResolver)paramAnnotated.getAnnotation(JsonTypeIdResolver.class);
  TypeIdResolver localTypeIdResolver1;
  if (localJsonTypeIdResolver == null)
    localTypeIdResolver1 = null;
  else
    localTypeIdResolver1 = paramMapperConfig.typeIdResolverInstance(paramAnnotated, localJsonTypeIdResolver.value());
  TypeIdResolver localTypeIdResolver2 = localTypeIdResolver1;
  if (localTypeIdResolver1 != null)
    localTypeIdResolver2.init(paramJavaType);
  TypeResolverBuilder localTypeResolverBuilder1 = ((TypeResolverBuilder)localObject).init(localJsonTypeInfo.use(), localTypeIdResolver2);
  JsonTypeInfo.As localAs1 = localJsonTypeInfo.include();
  JsonTypeInfo.As localAs2 = localAs1;
  if ((localAs1 == JsonTypeInfo.As.EXTERNAL_PROPERTY) && ((paramAnnotated instanceof AnnotatedClass)))
    localAs2 = JsonTypeInfo.As.PROPERTY;
  TypeResolverBuilder localTypeResolverBuilder2 = localTypeResolverBuilder1.inclusion(localAs2).typeProperty(localJsonTypeInfo.property());
  Class localClass = localJsonTypeInfo.defaultImpl();
  if (localClass != JsonTypeInfo.None.class)
    localTypeResolverBuilder2 = localTypeResolverBuilder2.defaultImpl(localClass);
  return localTypeResolverBuilder2.typeIdVisibility(localJsonTypeInfo.visible());
}
项目:QuizUpWinner    文件:BasicDeserializerFactory.java   
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));
}
项目:QuizUpWinner    文件:BasicDeserializerFactory.java   
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));
}
项目:codec    文件:CodecIntrospector.java   
@Override
public TypeResolverBuilder<?> findTypeResolver(MapperConfig<?> config, AnnotatedClass ac, JavaType baseType) {
    TypeResolverBuilder<?> annotationLookup = _findTypeResolver(config, ac, baseType);
    if (annotationLookup != null) {
        return annotationLookup;
    }
    if (pluginRegistry.byClass().containsKey(ac.getRawType())) {
        PluginMap pluginMap = pluginRegistry.byClass().get(ac.getRawType());
        return new CodecTypeResolverBuilder(pluginMap, config.getTypeFactory(), pluginRegistry);
    }
    return null;
}
项目:codec    文件:CodecIntrospector.java   
@Override
public TypeResolverBuilder<?> findPropertyTypeResolver(MapperConfig<?> config,
                                                       AnnotatedMember am, JavaType baseType)
{
    /* As per definition of @JsonTypeInfo, should only apply to contents of container
     * (collection, map) types, not container types themselves:
     */
    if (baseType.isContainerType()) return null;
    // No per-member type overrides (yet)
    return _findTypeResolver(config, am, baseType);
}
项目:codec    文件:CodecIntrospector.java   
@Override
public TypeResolverBuilder<?> findPropertyContentTypeResolver(MapperConfig<?> config,
                                                              AnnotatedMember am, JavaType containerType)
{
    /* First: let's ensure property is a container type: caller should have
     * verified but just to be sure
     */
    if (!containerType.isContainerType()) {
        throw new IllegalArgumentException("Must call method with a container type (got "+containerType+")");
    }
    return _findTypeResolver(config, am, containerType);
}
项目:codec    文件:CodecIntrospector.java   
public TypeResolverBuilder<?> _findTypeResolver(MapperConfig<?> config, Annotated ac, JavaType baseType) {
    Pluggable pluggable = ac.getAnnotation(Pluggable.class);
    if (pluggable != null) {
        PluginMap pluginMap = pluginRegistry.byCategory().get(pluggable.value());
        if (pluginMap != null) {
            return new CodecTypeResolverBuilder(pluginMap, config.getTypeFactory(), pluginRegistry);
        } else {
            log.warn("missing plugin map for {}, reached from {}", pluggable.value(), ac.getRawType());
        }
    }
    return null;
}
项目:joyplus-tv    文件:BaseSettings.java   
public BaseSettings withTypeResolverBuilder(TypeResolverBuilder<?> typer) {
    if (_typeResolverBuilder == typer) {
        return this;
    }
    return new BaseSettings(_classIntrospector, _annotationIntrospector, _visibilityChecker, _propertyNamingStrategy, _typeFactory,
            typer, _dateFormat, _handlerInstantiator, _locale,
            _timeZone, _defaultBase64);
}
项目:joyplus-tv    文件:MapperConfig.java   
/**
 * Method that can be called to obtain an instance of <code>TypeIdResolver</code> of
 * specified type.
 */
public TypeResolverBuilder<?> typeResolverBuilderInstance(Annotated annotated,
        Class<? extends TypeResolverBuilder<?>> builderClass)
{
    HandlerInstantiator hi = getHandlerInstantiator();
    if (hi != null) {
        TypeResolverBuilder<?> builder = hi.typeResolverBuilderInstance(this, annotated, builderClass);
        if (builder != null) {
            return builder;
        }
    }
    return (TypeResolverBuilder<?>) ClassUtil.createInstance(builderClass, canOverrideAccessModifiers());
}
项目:joyplus-tv    文件:BeanSerializerFactory.java   
/**
 * Method called to create a type information serializer for values of given
 * non-container property
 * if one is needed. If not needed (no polymorphic handling configured), should
 * return null.
 *
 * @param baseType Declared type to use as the base type for type information serializer
 * 
 * @return Type serializer to use for property values, if one is needed; null if not.
 */
public TypeSerializer findPropertyTypeSerializer(JavaType baseType,
        SerializationConfig config, AnnotatedMember accessor)
    throws JsonMappingException
{
    AnnotationIntrospector ai = config.getAnnotationIntrospector();
    TypeResolverBuilder<?> b = ai.findPropertyTypeResolver(config, accessor, baseType);        
    // Defaulting: if no annotations on member, check value class
    if (b == null) {
        return createTypeSerializer(config, baseType);
    }
    Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypes(
            accessor, config, ai, baseType);
    return b.buildTypeSerializer(config, baseType, subtypes);
}
项目:joyplus-tv    文件:AnnotationIntrospectorPair.java   
@Override
public TypeResolverBuilder<?> findTypeResolver(MapperConfig<?> config,
        AnnotatedClass ac, JavaType baseType)
{
    TypeResolverBuilder<?> b = _primary.findTypeResolver(config, ac, baseType);
    if (b == null) {
        b = _secondary.findTypeResolver(config, ac, baseType);
    }
    return b;
}
项目:joyplus-tv    文件:AnnotationIntrospectorPair.java   
@Override
public TypeResolverBuilder<?> findPropertyTypeResolver(MapperConfig<?> config,
        AnnotatedMember am, JavaType baseType)
{
    TypeResolverBuilder<?> b = _primary.findPropertyTypeResolver(config, am, baseType);
    if (b == null) {
        b = _secondary.findPropertyTypeResolver(config, am, baseType);
    }
    return b;
}
项目:joyplus-tv    文件:AnnotationIntrospectorPair.java   
@Override
public TypeResolverBuilder<?> findPropertyContentTypeResolver(MapperConfig<?> config,
        AnnotatedMember am, JavaType baseType)
{
    TypeResolverBuilder<?> b = _primary.findPropertyContentTypeResolver(config, am, baseType);
    if (b == null) {
        b = _secondary.findPropertyContentTypeResolver(config, am, baseType);
    }
    return b;
}
项目:joyplus-tv    文件:JacksonAnnotationIntrospector.java   
@Override
public TypeResolverBuilder<?> findPropertyTypeResolver(MapperConfig<?> config,
        AnnotatedMember am, JavaType baseType)
{
    /* As per definition of @JsonTypeInfo, should only apply to contents of container
     * (collection, map) types, not container types themselves:
     */
    if (baseType.isContainerType()) return null;
    // No per-member type overrides (yet)
    return _findTypeResolver(config, am, baseType);
}
项目:joyplus-tv    文件:JacksonAnnotationIntrospector.java   
@Override
public TypeResolverBuilder<?> findPropertyContentTypeResolver(MapperConfig<?> config,
        AnnotatedMember am, JavaType containerType)
{
    /* First: let's ensure property is a container type: caller should have
     * verified but just to be sure
     */
    if (!containerType.isContainerType()) {
        throw new IllegalArgumentException("Must call method with a container type (got "+containerType+")");
    }
    return _findTypeResolver(config, am, containerType);
}
项目:joyplus-tv    文件:BasicDeserializerFactory.java   
@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);
}
项目:joynr    文件:JsonMessageSerializerModule.java   
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);
}
项目:JRediClients    文件:JsonJacksonCodec.java   
protected void initTypeInclusion(ObjectMapper mapObjectMapper) {
    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;
                }
                if (t.getRawClass() == XMLGregorianCalendar.class) {
                    return false;
                }
                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);

    // warm up codec
    try {
        byte[] s = mapObjectMapper.writeValueAsBytes(1);
        mapObjectMapper.readValue(s, Object.class);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}