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


Java TypeIdResolver类代码示例

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


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

示例1: handleUnknownTypeId

import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; //导入依赖的package包/类
@Override
public JavaType handleUnknownTypeId(final DeserializationContext ctxt, final JavaType baseType,
                                    final String subTypeId, final TypeIdResolver idResolver,
                                    final String failureMsg) throws IOException {

    try {
        if (subTypeId.contains("org.jasig.")) {
            final String newTypeName = subTypeId.replaceAll("jasig", "apereo");
            LOGGER.warn("Found legacy CAS JSON definition type identified as [{}]. "
                            + "While CAS will attempt to convert the legacy definition to [{}] for the time being, "
                            + "the definition SHOULD manually be upgraded to the new supported syntax",
                    subTypeId, newTypeName);
            final Class newType = ClassUtils.getClass(newTypeName);
            return SimpleType.construct(newType);
        }
        return null;
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:21,代码来源:JasigRegisteredServiceDeserializationProblemHandler.java

示例2: idResolver

import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; //导入依赖的package包/类
protected TypeIdResolver idResolver(MapperConfig<?> paramMapperConfig, JavaType paramJavaType, Collection<NamedType> paramCollection, boolean paramBoolean1, boolean paramBoolean2)
{
  if (this._customIdResolver != null)
    return this._customIdResolver;
  if (this._idType == null)
    throw new IllegalStateException("Can not build, 'init()' not yet called");
  switch (1.$SwitchMap$com$fasterxml$jackson$annotation$JsonTypeInfo$Id[this._idType.ordinal()])
  {
  default:
    break;
  case 1:
    return new ClassNameIdResolver(paramJavaType, paramMapperConfig.getTypeFactory());
  case 2:
    return new MinimalClassNameIdResolver(paramJavaType, paramMapperConfig.getTypeFactory());
  case 3:
    return TypeNameIdResolver.construct(paramMapperConfig, paramJavaType, paramCollection, paramBoolean1, paramBoolean2);
  case 4:
    return null;
  }
  throw new IllegalStateException("Do not know how to construct standard type id resolver for idType: " + this._idType);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:22,代码来源:StdTypeResolverBuilder.java

示例3: buildTypeSerializer

import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; //导入依赖的package包/类
public TypeSerializer buildTypeSerializer(SerializationConfig config,
        JavaType baseType, Collection<NamedType> subtypes)
{
    if (_idType == JsonTypeInfo.Id.NONE) {
        return null;
    }
    TypeIdResolver idRes = idResolver(config, baseType, subtypes, true, false);
    switch (_includeAs) {
    case WRAPPER_ARRAY:
        return new AsArrayTypeSerializer(idRes, null);
    case PROPERTY:
        return new AsPropertyTypeSerializer(idRes, null,
                _typeProperty);
    case WRAPPER_OBJECT:
        return new AsWrapperTypeSerializer(idRes, null);
    case EXTERNAL_PROPERTY:
        return new AsExternalTypeSerializer(idRes, null,
                _typeProperty);
    }
    throw new IllegalStateException("Do not know how to construct standard type serializer for inclusion type: "+_includeAs);
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:22,代码来源:StdTypeResolverBuilder.java

示例4: buildTypeDeserializer

import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; //导入依赖的package包/类
public TypeDeserializer buildTypeDeserializer(DeserializationConfig config,
        JavaType baseType, Collection<NamedType> subtypes)
{
    if (_idType == JsonTypeInfo.Id.NONE) {
        return null;
    }

    TypeIdResolver idRes = idResolver(config, baseType, subtypes, false, true);
    
    // First, method for converting type info to type id:
    switch (_includeAs) {
    case WRAPPER_ARRAY:
        return new AsArrayTypeDeserializer(baseType, idRes,
                _typeProperty, _typeIdVisible, _defaultImpl);
    case PROPERTY:
        return new AsPropertyTypeDeserializer(baseType, idRes,
                _typeProperty, _typeIdVisible, _defaultImpl);
    case WRAPPER_OBJECT:
        return new AsWrapperTypeDeserializer(baseType, idRes,
                _typeProperty, _typeIdVisible, _defaultImpl);
    case EXTERNAL_PROPERTY:
        return new AsExternalTypeDeserializer(baseType, idRes,
                _typeProperty, _typeIdVisible, _defaultImpl);
    }
    throw new IllegalStateException("Do not know how to construct standard type serializer for inclusion type: "+_includeAs);
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:27,代码来源:StdTypeResolverBuilder.java

示例5: idResolver

import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; //导入依赖的package包/类
/**
 * Helper method that will either return configured custom
 * type id resolver, or construct a standard resolver
 * given configuration.
 */
protected TypeIdResolver idResolver(MapperConfig<?> config,
        JavaType baseType, Collection<NamedType> subtypes,
        boolean forSer, boolean forDeser)
{
    // Custom id resolver?
    if (_customIdResolver != null) {
        return _customIdResolver;
    }
    if (_idType == null) {
        throw new IllegalStateException("Can not build, 'init()' not yet called");
    }
    switch (_idType) {
    case CLASS:
        return new ClassNameIdResolver(baseType, config.getTypeFactory());
    case MINIMAL_CLASS:
        return new MinimalClassNameIdResolver(baseType, config.getTypeFactory());
    case NAME:
        return TypeNameIdResolver.construct(config, baseType, subtypes, forSer, forDeser);
    case NONE: // hmmh. should never get this far with 'none'
        return null;
    case CUSTOM: // need custom resolver...
    }
    throw new IllegalStateException("Do not know how to construct standard type id resolver for idType: "+_idType);
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:30,代码来源:StdTypeResolverBuilder.java

示例6: TypeDeserializerBase

import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; //导入依赖的package包/类
protected TypeDeserializerBase(JavaType baseType, TypeIdResolver idRes,
        String typePropertyName, boolean typeIdVisible, Class<?> defaultImpl)
{
    _baseType = baseType;
    _idResolver = idRes;
    _typePropertyName = typePropertyName;
    _typeIdVisible = typeIdVisible;
    _deserializers = new HashMap<String,JsonDeserializer<Object>>();
    if (defaultImpl == null) {
        _defaultImpl = null;
    } else {
        /* 16-Oct-2011, tatu: should call this via TypeFactory; this is
         *    not entirely safe... however, since Collections/Maps are
         *    seldom (if ever) base types, may be ok.
         */
        _defaultImpl = baseType.forcedNarrowBy(defaultImpl);
    }

    _property = null;
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:21,代码来源:TypeDeserializerBase.java

示例7: handleMissingTypeId

import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; //导入依赖的package包/类
@Override
public JavaType handleMissingTypeId(DeserializationContext ctxt, JavaType baseType, TypeIdResolver idResolver,
    String failureMsg) throws IOException {
  if (baseType.getRawClass() == Feature.class) {
    return idResolver.typeFromId(ctxt, "Feature");
  }
  return super.handleMissingTypeId(ctxt, baseType, idResolver, failureMsg);
}
 
开发者ID:dbmdz,项目名称:iiif-apis,代码行数:9,代码来源:ProblemHandler.java

示例8: AbstractTypedJacksonModule

import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; //导入依赖的package包/类
protected AbstractTypedJacksonModule(
        Class<T> baseClass,
        Function<T, String> nameResolver,
        Function<String, Class<? extends T>> classResolver)
{
    super(baseClass.getSimpleName() + "Module", Version.unknownVersion());

    TypeIdResolver typeResolver = new InternalTypeResolver<>(nameResolver, classResolver);

    addSerializer(baseClass, new InternalTypeSerializer<>(baseClass, typeResolver));
    addDeserializer(baseClass, new InternalTypeDeserializer<>(baseClass, typeResolver));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:13,代码来源:AbstractTypedJacksonModule.java

示例9: idResolver

import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; //导入依赖的package包/类
@Override
protected TypeIdResolver idResolver(MapperConfig<?> config, JavaType baseType, Collection<NamedType> subtypes, boolean forSer, boolean forDeser) {
    if (_customIdResolver != null) {
        return _customIdResolver;
    }
    if (_idType == null) {
        throw new IllegalStateException("Can not build, 'init()' not yet called");
    }
    if (_idType == JsonTypeInfo.Id.CLASS){
        return new WideningClassNameIdResolver(baseType, config.getTypeFactory());
    }
    return super.idResolver(config, baseType, subtypes, forSer, forDeser); //To change body of generated methods, choose Tools | Templates.
}
 
开发者ID:CIDARLAB,项目名称:clotho3crud,代码行数:14,代码来源:WideningDefaultTypeResolverBuilder.java

示例10: idResolver

import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; //导入依赖的package包/类
@Override
protected TypeIdResolver idResolver(MapperConfig<?> config, JavaType baseType, Collection<NamedType> subtypes,
        boolean forSer, boolean forDeser) {

    if (_idType == null) {
        throw new IllegalStateException("Can not build, 'init()' not yet called");
    }

    return new NsTypeIdResolver(baseType, config.getTypeFactory(), basicMetaData);
}
 
开发者ID:Talend,项目名称:components,代码行数:11,代码来源:NsTypeResolverBuilder.java

示例11: typeIdResolverInstance

import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; //导入依赖的package包/类
public TypeIdResolver typeIdResolverInstance(Annotated paramAnnotated, Class<? extends TypeIdResolver> paramClass)
{
  HandlerInstantiator localHandlerInstantiator = getHandlerInstantiator();
  if (localHandlerInstantiator != null)
  {
    TypeIdResolver localTypeIdResolver = localHandlerInstantiator.typeIdResolverInstance(this, paramAnnotated, paramClass);
    if (localTypeIdResolver != null)
      return localTypeIdResolver;
  }
  return (TypeIdResolver)ClassUtil.createInstance(paramClass, canOverrideAccessModifiers());
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:12,代码来源:MapperConfig.java

示例12: init

import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; //导入依赖的package包/类
public StdTypeResolverBuilder init(JsonTypeInfo.Id paramId, TypeIdResolver paramTypeIdResolver)
{
  if (paramId == null)
    throw new IllegalArgumentException("idType can not be null");
  this._idType = paramId;
  this._customIdResolver = paramTypeIdResolver;
  this._typeProperty = paramId.getDefaultPropertyName();
  return this;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:10,代码来源:StdTypeResolverBuilder.java

示例13: TypeDeserializerBase

import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; //导入依赖的package包/类
protected TypeDeserializerBase(JavaType paramJavaType, TypeIdResolver paramTypeIdResolver, String paramString, boolean paramBoolean, Class<?> paramClass)
{
  this._baseType = paramJavaType;
  this._idResolver = paramTypeIdResolver;
  this._typePropertyName = paramString;
  this._typeIdVisible = paramBoolean;
  this._deserializers = new HashMap();
  if (paramClass == null)
    this._defaultImpl = null;
  else
    this._defaultImpl = paramJavaType.forcedNarrowBy(paramClass);
  this._property = null;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:14,代码来源:TypeDeserializerBase.java

示例14: _findTypeResolver

import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; //导入依赖的package包/类
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());
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:40,代码来源:JacksonAnnotationIntrospector.java

示例15: buildTypeSerializer

import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; //导入依赖的package包/类
@Override
public TypeSerializer buildTypeSerializer(SerializationConfig config, JavaType baseType, Collection<NamedType> subtypes) {
	TypeIdResolver idRes = TypeNameIdResolver.construct(config, baseType, subtypes, true, false);
	return new AsPropertyTypeSerializer(idRes, null, "type") {

		protected String idFromValue(Object value) {
			return ((NamedDefinition) value).name();
		}
	};
}
 
开发者ID:Treydone,项目名称:mandrel,代码行数:11,代码来源:DynamicPropertyTypeResolver.java


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