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

com.github.TKnudsen.ComplexDataObject.model.io.json.ObjectMapperFactory Maven / Gradle / Ivy

Go to download

A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.

There is a newer version: 0.2.13
Show newest version
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);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy