本文整理匯總了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);
}