本文整理汇总了Java中com.fasterxml.jackson.databind.DeserializationConfig类的典型用法代码示例。如果您正苦于以下问题:Java DeserializationConfig类的具体用法?Java DeserializationConfig怎么用?Java DeserializationConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DeserializationConfig类属于com.fasterxml.jackson.databind包,在下文中一共展示了DeserializationConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupModule
import com.fasterxml.jackson.databind.DeserializationConfig; //导入依赖的package包/类
@Override
public void setupModule(final SetupContext context) {
super.setupModule(context);
context.addBeanDeserializerModifier(new BeanDeserializerModifier() {
@Override
public JsonDeserializer<?> modifyCollectionDeserializer(final DeserializationConfig config,
final CollectionType type,
final BeanDescription beanDesc,
final JsonDeserializer<?> deserializer) {
if (deserializer instanceof CollectionDeserializer) {
return new ListDeserializer((CollectionDeserializer) deserializer);
} else {
return super.modifyCollectionDeserializer(config, type, beanDesc,
deserializer);
}
}
});
}
示例2: modifyMapDeserializer
import com.fasterxml.jackson.databind.DeserializationConfig; //导入依赖的package包/类
@Override
public JsonDeserializer<?> modifyMapDeserializer(
DeserializationConfig config, MapType type,
BeanDescription beanDesc,
JsonDeserializer<?> deserializer) {
// statements
if (isMapOfStringAndListOfStatements(type)) {
return new ModifiedMapDeserializer<String, List<JacksonStatement>>(deserializer);
}
// labels and descriptions
else if (isMapOfStringAndMonolingualTextValue(type)) {
return new ModifiedMapDeserializer<String, JacksonMonolingualTextValue>(deserializer);
}
// sitelinks
else if (isMapOfStringAndSitelink(type)) {
return new ModifiedMapDeserializer<String, JacksonSiteLink>(deserializer);
}
// aliases and miscallaneous that does not need this workaround
else {
return deserializer;
}
}
示例3: objectMapper
import com.fasterxml.jackson.databind.DeserializationConfig; //导入依赖的package包/类
@Bean
public ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
SimpleModule module = new SimpleModule();
module.setDeserializerModifier( new BeanDeserializerModifier() {
@Override
public JsonDeserializer<Enum> modifyEnumDeserializer( DeserializationConfig config, final JavaType type, BeanDescription beanDesc,
final JsonDeserializer<?> deserializer ) {
return new JsonDeserializer<Enum>() {
@Override
public Enum deserialize( JsonParser jp, DeserializationContext ctxt ) throws IOException {
Class<? extends Enum> rawClass = (Class<Enum<?>>) type.getRawClass();
return Enum.valueOf( rawClass, jp.getValueAsString().toUpperCase() );
}
};
}
} );
module.addDeserializer( Expression.class, new ExpressionDeserializer( expressionParser() ) );
module.addDeserializer( Range.class, new RangeDeserializer() );
mapper.registerModule( module );
return mapper;
}
示例4: setup
import com.fasterxml.jackson.databind.DeserializationConfig; //导入依赖的package包/类
@Before
public void setup() {
typeResolver = mock(TypeResolver.class);
configuration = Configuration.build();
instantiator = mock(HandlerInstantiator.class);
doReturn(new ResourceDeserializer(Object.class, typeResolver, configuration))
.when(instantiator).deserializerInstance(any(DeserializationConfig.class),
any(Annotated.class), eq(ResourceDeserializer.class));
mapper = new ObjectMapper();
mapper.setHandlerInstantiator(instantiator);
mapper.registerModule(new Jackson2HalModule());
mapper.registerModule(new TestModule());
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
示例5: buildTypeDeserializer
import com.fasterxml.jackson.databind.DeserializationConfig; //导入依赖的package包/类
public TypeDeserializer buildTypeDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, Collection<NamedType> paramCollection)
{
if (this._idType == JsonTypeInfo.Id.NONE)
return null;
TypeIdResolver localTypeIdResolver = idResolver(paramDeserializationConfig, paramJavaType, paramCollection, false, true);
switch (1.$SwitchMap$com$fasterxml$jackson$annotation$JsonTypeInfo$As[this._includeAs.ordinal()])
{
default:
break;
case 1:
return new AsArrayTypeDeserializer(paramJavaType, localTypeIdResolver, this._typeProperty, this._typeIdVisible, this._defaultImpl);
case 2:
return new AsPropertyTypeDeserializer(paramJavaType, localTypeIdResolver, this._typeProperty, this._typeIdVisible, this._defaultImpl);
case 3:
return new AsWrapperTypeDeserializer(paramJavaType, localTypeIdResolver, this._typeProperty, this._typeIdVisible, this._defaultImpl);
case 4:
return new AsExternalTypeDeserializer(paramJavaType, localTypeIdResolver, this._typeProperty, this._typeIdVisible, this._defaultImpl);
}
throw new IllegalStateException("Do not know how to construct standard type serializer for inclusion type: " + this._includeAs);
}
示例6: deserializerInstance
import com.fasterxml.jackson.databind.DeserializationConfig; //导入依赖的package包/类
@Override
public JsonDeserializer<?> deserializerInstance(DeserializationConfig config, Annotated annotated, Class<?> deserClass) {
try{
if(MigrationDeserializer.class.equals(deserClass)) {
return migrationDeserializer;
} else if(None.class.equals(deserClass)) {
return null;
}
System.out.println("DeserializationConfig " + config);
System.out.println("Annotated " + annotated);
System.out.println("deserClass Class<?> " + deserClass);
return (JsonDeserializer<?>) deserClass.newInstance();
}catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
示例7: findCollectionDeserializer
import com.fasterxml.jackson.databind.DeserializationConfig; //导入依赖的package包/类
@Override
public JsonDeserializer<?> findCollectionDeserializer(CollectionType type, DeserializationConfig config, BeanDescription beanDesc,
TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException
{
Class<?> raw = type.getRawClass();
if (CollectionF.class.isAssignableFrom(raw)) {
if (Option.class.isAssignableFrom(raw)) {
return new OptionDeserializer(type, elementTypeDeserializer, elementDeserializer);
}
if (ListF.class.isAssignableFrom(raw)) {
return new ListFDeserializer(type, elementTypeDeserializer, elementDeserializer);
}
if (SetF.class.isAssignableFrom(raw)) {
return new SetFDeserializer(type, elementTypeDeserializer, elementDeserializer);
}
return new ListFDeserializer(type, elementTypeDeserializer, elementDeserializer);
}
return null;
}
示例8: _valueInstantiatorInstance
import com.fasterxml.jackson.databind.DeserializationConfig; //导入依赖的package包/类
public ValueInstantiator _valueInstantiatorInstance(DeserializationConfig paramDeserializationConfig, Annotated paramAnnotated, Object paramObject)
{
if (paramObject == null)
return null;
if ((paramObject instanceof ValueInstantiator))
return (ValueInstantiator)paramObject;
if (!(paramObject instanceof Class))
throw new IllegalStateException("AnnotationIntrospector returned key deserializer definition of type " + paramObject.getClass().getName() + "; expected type KeyDeserializer or Class<KeyDeserializer> instead");
Class localClass = (Class)paramObject;
if (localClass == NoClass.class)
return null;
if (!ValueInstantiator.class.isAssignableFrom(localClass))
throw new IllegalStateException("AnnotationIntrospector returned Class " + localClass.getName() + "; expected Class<ValueInstantiator>");
HandlerInstantiator localHandlerInstantiator = paramDeserializationConfig.getHandlerInstantiator();
if (localHandlerInstantiator != null)
{
ValueInstantiator localValueInstantiator = localHandlerInstantiator.valueInstantiatorInstance(paramDeserializationConfig, paramAnnotated, localClass);
if (localValueInstantiator != null)
return localValueInstantiator;
}
return (ValueInstantiator)ClassUtil.createInstance(localClass, paramDeserializationConfig.canOverrideAccessModifiers());
}
示例9: findTypeDeserializer
import com.fasterxml.jackson.databind.DeserializationConfig; //导入依赖的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);
}
示例10: deserializerForCreator
import com.fasterxml.jackson.databind.DeserializationConfig; //导入依赖的package包/类
public static JsonDeserializer<?> deserializerForCreator(DeserializationConfig paramDeserializationConfig, Class<?> paramClass, AnnotatedMethod paramAnnotatedMethod)
{
Class localClass = paramAnnotatedMethod.getRawParameterType(0);
Object localObject;
if (localClass == String.class)
localObject = null;
else if ((localClass == Integer.TYPE) || (localClass == Integer.class))
localObject = Integer.class;
else if ((localClass == Long.TYPE) || (localClass == Long.class))
localObject = Long.class;
else
throw new IllegalArgumentException("Parameter #0 type for factory method (" + paramAnnotatedMethod + ") not suitable, must be java.lang.String or int/Integer/long/Long");
if (paramDeserializationConfig.canOverrideAccessModifiers())
ClassUtil.checkAndFixAccess(paramAnnotatedMethod.getMember());
return new FactoryBasedDeserializer(paramClass, paramAnnotatedMethod, (Class)localObject);
}
示例11: _createDeserializer
import com.fasterxml.jackson.databind.DeserializationConfig; //导入依赖的package包/类
protected final JsonDeserializer<Object> _createDeserializer(DeserializationContext paramDeserializationContext, DeserializerFactory paramDeserializerFactory, JavaType paramJavaType)
{
DeserializationConfig localDeserializationConfig = paramDeserializationContext.getConfig();
if ((paramJavaType.isAbstract()) || (paramJavaType.isMapLikeType()) || (paramJavaType.isCollectionLikeType()))
paramJavaType = paramDeserializerFactory.mapAbstractType(localDeserializationConfig, paramJavaType);
BeanDescription localBeanDescription = localDeserializationConfig.introspect(paramJavaType);
JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationContext, localBeanDescription.getClassInfo());
if (localJsonDeserializer != null)
return localJsonDeserializer;
JavaType localJavaType1 = modifyTypeByAnnotation(paramDeserializationContext, localBeanDescription.getClassInfo(), paramJavaType);
if (localJavaType1 != paramJavaType)
{
paramJavaType = localJavaType1;
localBeanDescription = localDeserializationConfig.introspect(localJavaType1);
}
Class localClass = localBeanDescription.findPOJOBuilder();
if (localClass != null)
return paramDeserializerFactory.createBuilderBasedDeserializer(paramDeserializationContext, paramJavaType, localBeanDescription, localClass);
Converter localConverter = localBeanDescription.findDeserializationConverter();
if (localConverter == null)
return _createDeserializer2(paramDeserializationContext, paramDeserializerFactory, paramJavaType, localBeanDescription);
JavaType localJavaType2 = localConverter.getInputType(paramDeserializationContext.getTypeFactory());
if (!localJavaType2.hasRawClass(paramJavaType.getRawClass()))
localBeanDescription = localDeserializationConfig.introspect(localJavaType2);
return new StdDelegatingDeserializer(localConverter, localJavaType2, _createDeserializer2(paramDeserializationContext, paramDeserializerFactory, localJavaType2, localBeanDescription));
}
示例12: modifyEnumDeserializer
import com.fasterxml.jackson.databind.DeserializationConfig; //导入依赖的package包/类
@Override
public JsonDeserializer<?> modifyEnumDeserializer(DeserializationConfig config, JavaType type,
BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
if (Arrays.asList(Quality.class, Format.class).contains(type.getRawClass())) {
return new EnumDeserializer((Class<? extends Enum>) type.getRawClass());
}
return super.modifyEnumDeserializer(config, type, beanDesc, deserializer);
}
示例13: modifyDeserializer
import com.fasterxml.jackson.databind.DeserializationConfig; //导入依赖的package包/类
@Override
public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc,
JsonDeserializer<?> deserializer) {
// We don't use the @JsonDeserialize annotation since we only want the
// custom deserializer for the abstract type and not for the actual types.
if (Service.class == beanDesc.getBeanClass()) {
return new ServiceDeserializer();
} else if (Resource.class == beanDesc.getBeanClass()) {
return new ResourceDeserializer();
} else if (Profile.class == beanDesc.getBeanClass()) {
return new ProfileDeserializer((JsonDeserializer<Object>) deserializer);
}
return super.modifyDeserializer(config, beanDesc, deserializer);
}
示例14: findValueInstantiator
import com.fasterxml.jackson.databind.DeserializationConfig; //导入依赖的package包/类
@Override
public ValueInstantiator findValueInstantiator(DeserializationConfig config, BeanDescription beanDesc,
ValueInstantiator defaultInstantiator) {
if (DEFAULT_NO_DESER_CLASS_NAMES.contains(beanDesc.getClassInfo().getRawType().getName())) {
throw new IllegalArgumentException("Illegal type " + beanDesc.getClassInfo().getRawType().getName() + " to deserialize: prevented for security reasons");
}
return super.findValueInstantiator(config, beanDesc, defaultInstantiator);
}
示例15: modifyEnumDeserializer
import com.fasterxml.jackson.databind.DeserializationConfig; //导入依赖的package包/类
@Override
public JsonDeserializer<Enum> modifyEnumDeserializer(DeserializationConfig config,
final JavaType type,
BeanDescription beanDesc,
final JsonDeserializer<?> deserializer) {
return new EnumJsonDeserializer(type);
}