All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.smecsia.gawain.jackson.ObjectMapperProvider Maven / Gradle / Ivy

Go to download

Microframework focusing on data processing and aggregation in distributed environment

There is a newer version: 0.1.9
Show newest version
package me.smecsia.gawain.jackson;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.PropertyAccessor.FIELD;
import static com.fasterxml.jackson.annotation.PropertyAccessor.GETTER;
import static com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping.NON_FINAL;

/**
 * @author Ilya Sadykov
 */
public class ObjectMapperProvider {

    public ObjectMapper provide() {
        ObjectMapper result = new ObjectMapper();
        result.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        result.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        result.setVisibility(FIELD, ANY);
        result.setVisibility(GETTER, NONE);
        result.registerModule(new JavaTimeModule());
        result.registerModule(new GawainJacksonModule());
        result.enableDefaultTyping(NON_FINAL);
        return result;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy