Search in sources :

Example 1 with MultiFilter

use of org.candlepin.common.jackson.MultiFilter in project candlepin by candlepin.

the class JsonProvider method configureHateoasObjectMapper.

private void configureHateoasObjectMapper(ObjectMapper mapper, boolean indentJson) {
    mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    if (indentJson) {
        mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
    }
    SimpleFilterProvider filterProvider = new SimpleFilterProvider();
    filterProvider = filterProvider.addFilter("ConsumerFilter", new MultiFilter(new HateoasBeanPropertyFilter(), new DynamicPropertyFilter()));
    filterProvider = filterProvider.addFilter("EntitlementFilter", new MultiFilter(new HateoasBeanPropertyFilter(), new DynamicPropertyFilter()));
    filterProvider = filterProvider.addFilter("OwnerFilter", new MultiFilter(new HateoasBeanPropertyFilter(), new DynamicPropertyFilter()));
    filterProvider = filterProvider.addFilter("GuestFilter", new MultiFilter(new HateoasBeanPropertyFilter(), new DynamicPropertyFilter()));
    filterProvider.setDefaultFilter(new DynamicPropertyFilter());
    filterProvider.setFailOnUnknownId(false);
    mapper.setFilterProvider(filterProvider);
    AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(mapper.getTypeFactory());
    AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary);
    mapper.setAnnotationIntrospector(pair);
}
Also used : JacksonAnnotationIntrospector(com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector) AnnotationIntrospectorPair(com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) HateoasBeanPropertyFilter(org.candlepin.common.jackson.HateoasBeanPropertyFilter) JacksonAnnotationIntrospector(com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector) AnnotationIntrospector(com.fasterxml.jackson.databind.AnnotationIntrospector) JaxbAnnotationIntrospector(com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector) DynamicPropertyFilter(org.candlepin.common.jackson.DynamicPropertyFilter) MultiFilter(org.candlepin.common.jackson.MultiFilter) JaxbAnnotationIntrospector(com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector)

Aggregations

AnnotationIntrospector (com.fasterxml.jackson.databind.AnnotationIntrospector)1 AnnotationIntrospectorPair (com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair)1 JacksonAnnotationIntrospector (com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector)1 SimpleFilterProvider (com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider)1 JaxbAnnotationIntrospector (com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector)1 DynamicPropertyFilter (org.candlepin.common.jackson.DynamicPropertyFilter)1 HateoasBeanPropertyFilter (org.candlepin.common.jackson.HateoasBeanPropertyFilter)1 MultiFilter (org.candlepin.common.jackson.MultiFilter)1