當前位置: 首頁>>代碼示例>>Java>>正文


Java DeserializationConfig類代碼示例

本文整理匯總了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);
            }
        }
    });
}
 
開發者ID:allure-framework,項目名稱:allure2,代碼行數:19,代碼來源:XmlParserModule.java

示例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;
	}
}
 
開發者ID:heindorf,項目名稱:cikm16-wdvd-feature-extraction,代碼行數:24,代碼來源:MapDeserializerModifier.java

示例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;
}
 
開發者ID:cslee00,項目名稱:datadog-jmx-collector,代碼行數:25,代碼來源:JmxCollectorMain.java

示例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);
}
 
開發者ID:BlackPepperSoftware,項目名稱:bowman,代碼行數:18,代碼來源:ResourceDeserializerTest.java

示例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);
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:21,代碼來源:StdTypeResolverBuilder.java

示例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);
}
  }
 
開發者ID:ludup,項目名稱:hypersocket-framework,代碼行數:19,代碼來源:MigrationHandlerInstantiator.java

示例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;
}
 
開發者ID:v1ctor,項目名稱:jackson-datatype-bolts,代碼行數:20,代碼來源:BoltsDeserializers.java

示例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());
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:23,代碼來源:BasicDeserializerFactory.java

示例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);
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:27,代碼來源:BasicDeserializerFactory.java

示例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);
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:17,代碼來源:EnumDeserializer.java

示例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));
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:27,代碼來源:DeserializerCache.java

示例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);
}
 
開發者ID:dbmdz,項目名稱:iiif-apis,代碼行數:9,代碼來源:DeserializerModifier.java

示例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);
}
 
開發者ID:dbmdz,項目名稱:iiif-apis,代碼行數:15,代碼來源:DeserializerModifier.java

示例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);
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:10,代碼來源:DefenceModule.java

示例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);

}
 
開發者ID:orshachar,項目名稱:known-issue,代碼行數:9,代碼來源:JacksonEnumExtension.java


注:本文中的com.fasterxml.jackson.databind.DeserializationConfig類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。