
com.enofex.naikan.model.module.ObjectMapperFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of naikan-model Show documentation
Show all versions of naikan-model Show documentation
The Naikan Model Module for Naikan the software inventory management tool for dev teams driven
by our CI/CD pipeline.
The newest version!
package com.enofex.naikan.model.module;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import java.io.IOException;
import java.io.Serial;
public final class ObjectMapperFactory {
private ObjectMapperFactory() {
}
public static ObjectMapper newObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
mapper.registerModule(new NaikanModule());
mapper.enable(JsonGenerator.Feature.IGNORE_UNKNOWN);
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
SimpleModule stringModule = new SimpleModule();
stringModule.addSerializer(new TrimStringSerializer());
mapper.registerModule(stringModule);
return mapper;
}
private static final class TrimStringSerializer extends StdScalarSerializer
© 2015 - 2025 Weber Informatics LLC | Privacy Policy