本文整理汇总了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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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));
}
示例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.
}
示例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);
}
示例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());
}
示例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;
}
示例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;
}
示例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());
}
示例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();
}
};
}