Search in sources :

Example 1 with PropertyWriter

use of com.fasterxml.jackson.databind.ser.PropertyWriter in project eureka by Netflix.

the class AbstractEurekaJacksonCodec method bindAmazonInfoFilter.

private void bindAmazonInfoFilter(ObjectMapper mapper) {
    SimpleFilterProvider filters = new SimpleFilterProvider();
    final String filterName = "exclude-amazon-info-entries";
    mapper.setAnnotationIntrospector(new JacksonAnnotationIntrospector() {

        @Override
        public Object findFilterId(Annotated a) {
            if (Map.class.isAssignableFrom(a.getRawType())) {
                return filterName;
            }
            return super.findFilterId(a);
        }
    });
    filters.addFilter(filterName, new SimpleBeanPropertyFilter() {

        @Override
        protected boolean include(BeanPropertyWriter writer) {
            return true;
        }

        @Override
        protected boolean include(PropertyWriter writer) {
            return MINI_AMAZON_INFO_INCLUDE_KEYS.contains(writer.getName());
        }
    });
    mapper.setFilters(filters);
}
Also used : JacksonAnnotationIntrospector(com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) Annotated(com.fasterxml.jackson.databind.introspect.Annotated) SimpleBeanPropertyFilter(com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter) Map(java.util.Map) BeanPropertyWriter(com.fasterxml.jackson.databind.ser.BeanPropertyWriter) BeanPropertyWriter(com.fasterxml.jackson.databind.ser.BeanPropertyWriter) PropertyWriter(com.fasterxml.jackson.databind.ser.PropertyWriter)

Aggregations

Annotated (com.fasterxml.jackson.databind.introspect.Annotated)1 JacksonAnnotationIntrospector (com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector)1 BeanPropertyWriter (com.fasterxml.jackson.databind.ser.BeanPropertyWriter)1 PropertyWriter (com.fasterxml.jackson.databind.ser.PropertyWriter)1 SimpleBeanPropertyFilter (com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter)1 SimpleFilterProvider (com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider)1 Map (java.util.Map)1