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

com.shopify.mappers.ShopifySdkObjectMapper Maven / Gradle / Ivy

There is a newer version: 2.9.3
Show newest version
package com.shopify.mappers;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;

public class ShopifySdkObjectMapper {

	private ShopifySdkObjectMapper() {
	}

	public static ObjectMapper buildMapper() {
		final ObjectMapper mapper = new ObjectMapper();
		mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
		mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

		final AnnotationIntrospector pair = AnnotationIntrospector.pair(
				new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()), new JacksonAnnotationIntrospector());
		mapper.setAnnotationIntrospector(pair);

		mapper.enable(MapperFeature.USE_ANNOTATIONS);
		return mapper;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy