ObjectMapperFactory.java
- /*
- * This file is part of the pl.wrzasq.lambda.
- *
- * @license http://mit-license.org/ The MIT license
- * @copyright 2018 - 2019 © by Rafał Wrzeszcz - Wrzasq.pl.
- */
- package pl.wrzasq.lambda.json;
- import com.fasterxml.jackson.databind.DeserializationFeature;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.fasterxml.jackson.databind.SerializationFeature;
- import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
- /**
- * Default Jackson ObjectMapper provider.
- */
- public class ObjectMapperFactory {
- /**
- * Creates Jackson mapper.
- *
- * @return Object mapper to be used around the system.
- */
- public static ObjectMapper createObjectMapper() {
- var objectMapper = new ObjectMapper();
- objectMapper.registerModule(new JavaTimeModule());
- objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
- objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- objectMapper.configure(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE, false);
- return objectMapper;
- }
- }