com.fasterxml.jackson.databind.cfg.DeserializerFactoryConfig Java Examples

The following examples show how to use com.fasterxml.jackson.databind.cfg.DeserializerFactoryConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectMapperProvider.java    From icure-backend with GNU General Public License v2.0 6 votes vote down vote up
@Override
public ObjectMapper getContext(Class<?> type) {
	// TypeResolver
	SimpleAbstractTypeResolver abstractTypeResolver = new SimpleAbstractTypeResolver();
	abstractTypeResolver.addMapping(List.class, ArrayList.class);
	abstractTypeResolver.addMapping(Set.class, HashSet.class);
	abstractTypeResolver.addMapping(Map.class, HashMap.class);

	// Serializer
	DefaultSerializerProvider serializerProvider = new DefaultSerializerProvider.Impl();

	// Deserializer
	DeserializerFactoryConfig deserializerFactoryConfig = new DeserializerFactoryConfig().withAbstractTypeResolver(abstractTypeResolver);
	BeanDeserializerFactory deserializerFactory = new BeanDeserializerFactory(deserializerFactoryConfig);
	DefaultDeserializationContext.Impl deserializationContext = new DefaultDeserializationContext.Impl(deserializerFactory);

	// ObjectMapper
	ObjectMapper objectMapper = new ObjectMapper(null, serializerProvider, deserializationContext);
	objectMapper = objectMapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.OBJECT_AND_NON_CONCRETE, "type");
	objectMapper = objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
	objectMapper = objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);

	return objectMapper;
}
 
Example #2
Source File: BeanDeserializerFactory.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method used by module registration functionality, to construct a new bean
 * deserializer factory
 * with different configuration settings.
 */
@Override
public DeserializerFactory withConfig(DeserializerFactoryConfig config)
{
    if (_factoryConfig == config) {
        return this;
    }
    /* 22-Nov-2010, tatu: Handling of subtypes is tricky if we do immutable-with-copy-ctor;
     *    and we pretty much have to here either choose between losing subtype instance
     *    when registering additional deserializers, or losing deserializers.
     *    Instead, let's actually just throw an error if this method is called when subtype
     *    has not properly overridden this method; this to indicate problem as soon as possible.
     */
    ClassUtil.verifyMustOverride(BeanDeserializerFactory.class, this, "withConfig");
    return new BeanDeserializerFactory(config);
}
 
Example #3
Source File: ObjectMapperFactoryV2.java    From aws-athena-query-federation with Apache License 2.0 5 votes vote down vote up
@Override
public DeserializerFactory withConfig(DeserializerFactoryConfig config)
{
    if (_factoryConfig == config) {
        return this;
    }
    return new StrictDeserializerFactory(config);
}
 
Example #4
Source File: ObjectMapperFactoryV2.java    From aws-athena-query-federation with Apache License 2.0 5 votes vote down vote up
private StrictObjectMapper(BlockAllocator allocator)
{
    super(JSON_FACTORY);
    _serializerFactory = SERIALIZER_FACTORY;

    ImmutableMap<Class<?>, JsonDeserializer<?>> desers = ImmutableMap.of(
            FederationRequest.class, createRequestDeserializer(allocator),
            FederationResponse.class, createResponseDeserializer(allocator),
            LambdaFunctionException.class, new LambdaFunctionExceptionSerDe.Deserializer());
    SimpleDeserializers deserializers = new SimpleDeserializers(desers);
    DeserializerFactoryConfig dConfig = new DeserializerFactoryConfig().withAdditionalDeserializers(deserializers);
    _deserializationContext = new DefaultDeserializationContext.Impl(new StrictDeserializerFactory(dConfig));
    // required by LambdaInvokerFactory
    disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
}
 
Example #5
Source File: ObjectMapperFactoryV2.java    From aws-athena-query-federation with Apache License 2.0 4 votes vote down vote up
private StrictDeserializerFactory(DeserializerFactoryConfig config)
{
    super(config);
}
 
Example #6
Source File: Jackson2ObjectMapperBuilderTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private static DeserializerFactoryConfig getDeserializerFactoryConfig(ObjectMapper objectMapper) {
	return ((BasicDeserializerFactory) objectMapper.getDeserializationContext().getFactory()).getFactoryConfig();
}
 
Example #7
Source File: Jackson2ObjectMapperFactoryBeanTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private static DeserializerFactoryConfig getDeserializerFactoryConfig(ObjectMapper objectMapper) {
	return ((BasicDeserializerFactory) objectMapper.getDeserializationContext().getFactory()).getFactoryConfig();
}
 
Example #8
Source File: Jackson2ObjectMapperBuilderTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
private static DeserializerFactoryConfig getDeserializerFactoryConfig(ObjectMapper objectMapper) {
	return ((BasicDeserializerFactory) objectMapper.getDeserializationContext().getFactory()).getFactoryConfig();
}
 
Example #9
Source File: Jackson2ObjectMapperFactoryBeanTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
private static DeserializerFactoryConfig getDeserializerFactoryConfig(ObjectMapper objectMapper) {
	return ((BasicDeserializerFactory) objectMapper.getDeserializationContext().getFactory()).getFactoryConfig();
}
 
Example #10
Source File: BasicDeserializerFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected BasicDeserializerFactory(DeserializerFactoryConfig config) {
    _factoryConfig = config;
}
 
Example #11
Source File: BeanDeserializerFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public BeanDeserializerFactory(DeserializerFactoryConfig config) {
    super(config);
}
 
Example #12
Source File: CustomBeanDeserializerFactory.java    From caravan with Apache License 2.0 4 votes vote down vote up
public CustomBeanDeserializerFactory(DeserializerFactoryConfig config) {
  super(config);
}
 
Example #13
Source File: Jackson2ObjectMapperBuilderTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private static DeserializerFactoryConfig getDeserializerFactoryConfig(ObjectMapper objectMapper) {
	return ((BasicDeserializerFactory) objectMapper.getDeserializationContext().getFactory()).getFactoryConfig();
}
 
Example #14
Source File: Jackson2ObjectMapperFactoryBeanTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private static DeserializerFactoryConfig getDeserializerFactoryConfig(ObjectMapper objectMapper) {
	return ((BasicDeserializerFactory) objectMapper.getDeserializationContext().getFactory()).getFactoryConfig();
}
 
Example #15
Source File: BasicDeserializerFactory.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Method for getting current {@link DeserializerFactoryConfig}.
  *<p>
 * Note that since instances are immutable, you can NOT change settings
 * by accessing an instance and calling methods: this will simply create
 * new instance of config object.
 */
public DeserializerFactoryConfig getFactoryConfig() {
    return _factoryConfig;
}
 
Example #16
Source File: BasicDeserializerFactory.java    From lams with GNU General Public License v2.0 votes vote down vote up
protected abstract DeserializerFactory withConfig(DeserializerFactoryConfig config);