com.dropchop.textonic.rest.jackson.client.TextonicObjectMapperFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of textonic-client Show documentation
Show all versions of textonic-client Show documentation
Dropchop's Textonic Java REST API and Client.
package com.dropchop.textonic.rest.jackson.client;
import com.dropchop.recyclone.model.api.attr.Attribute;
import com.dropchop.recyclone.rest.jackson.client.AttributeCompactSerializer;
import com.dropchop.recyclone.rest.jackson.client.AttributeDeserializer;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
/**
* @author Nikola Ivačič on 15. 11. 22.
*/
public class TextonicObjectMapperFactory {
public static ObjectMapper createMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
//mapper.disable(SerializationFeature.WRITE_SELF_REFERENCES_AS_NULL);
SimpleModule module = new SimpleModule();
module.addDeserializer(Attribute.class, new AttributeDeserializer());
module.addSerializer(new AttributeCompactSerializer());
mapper.registerModule(new Jdk8Module());
mapper.registerModule(new JavaTimeModule());
mapper.registerModule(new ParameterNamesModule());
mapper.registerModule(module);
return mapper;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy