io.split.client.ObjectMapperProvider Maven / Gradle / Ivy
package io.split.client;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
/**
* Provider of ObjectMapper.
*
* @author adil
*/
@Provider
public class ObjectMapperProvider implements ContextResolver {
final ObjectMapper defaultObjectMapper;
public ObjectMapperProvider() {
defaultObjectMapper = createDefaultMapper();
}
@Override
public ObjectMapper getContext(final Class> type) {
return defaultObjectMapper;
}
private static ObjectMapper createDefaultMapper() {
final ObjectMapper result = new ObjectMapper();
result.enable(SerializationFeature.INDENT_OUTPUT);
result.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy