com.github.TKnudsen.ComplexDataObject.model.io.json.ObjectMapperFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of complex-data-object Show documentation
Show all versions of complex-data-object Show documentation
A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.
package com.github.TKnudsen.ComplexDataObject.model.io.json;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
public class ObjectMapperFactory {
private static ObjectMapper complexDataObjectObjectMapper;
public static ObjectMapper getComplexDataObjectObjectMapper() {
if (complexDataObjectObjectMapper == null)
initComplexDataObjectObjectMapper();
return complexDataObjectObjectMapper;
}
private static void initComplexDataObjectObjectMapper() {
complexDataObjectObjectMapper = new ObjectMapper();
complexDataObjectObjectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
complexDataObjectObjectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
complexDataObjectObjectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
complexDataObjectObjectMapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE);
complexDataObjectObjectMapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
}
}