Java Code Examples for com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter#filterOutAllExcept()
The following examples show how to use
com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter#filterOutAllExcept() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JacksonObjectProvider.java From ameba with MIT License | 5 votes |
@Override @SuppressWarnings("unchecked") public PropertyFilter findPropertyFilter(final Object filterId, final Object valueToFilter) { if (filterId instanceof String) { final String id = (String) filterId; // FilterId should represent a class only in case of root entity is marshalled. if (id.equals(root.getEntityClass().getName())) { stack.clear(); return stack.push(root); } while (!stack.isEmpty()) { final FilteringPropertyFilter peek = stack.peek(); final FilteringPropertyFilter subfilter = peek.findSubfilter(id); if (subfilter != null) { stack.push(subfilter); // Need special handling for maps here - map keys can be filtered as well so we just say that every key is // allowed. if (valueToFilter instanceof Map) { final Map<String, ?> map = (Map<String, ?>) valueToFilter; return new FilteringPropertyFilter(Map.class, map.keySet(), Collections.emptyMap()); } return subfilter; } else { stack.pop(); } } } return SimpleBeanPropertyFilter.filterOutAllExcept(); }
Example 2
Source File: FilteringController.java From in28minutes-spring-microservices with MIT License | 3 votes |
@GetMapping("/filtering") public MappingJacksonValue retrieveSomeBean() { SomeBean someBean = new SomeBean("value1", "value2", "value3"); SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.filterOutAllExcept("field1", "field2"); FilterProvider filters = new SimpleFilterProvider().addFilter("SomeBeanFilter", filter); MappingJacksonValue mapping = new MappingJacksonValue(someBean); mapping.setFilters(filters); return mapping; }
Example 3
Source File: FilteringController.java From in28minutes-spring-microservices with MIT License | 3 votes |
@GetMapping("/filtering-list") public MappingJacksonValue retrieveListOfSomeBeans() { List<SomeBean> list = Arrays.asList(new SomeBean("value1", "value2", "value3"), new SomeBean("value12", "value22", "value32")); SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.filterOutAllExcept("field2", "field3"); FilterProvider filters = new SimpleFilterProvider().addFilter("SomeBeanFilter", filter); MappingJacksonValue mapping = new MappingJacksonValue(list); mapping.setFilters(filters); return mapping; }
Example 4
Source File: FilteringController.java From spring-web-services with MIT License | 3 votes |
@GetMapping("/filtering") public MappingJacksonValue retrieveSomeBean() { SomeBean someBean = new SomeBean("value1", "value2", "value3"); SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.filterOutAllExcept("field1", "field2"); FilterProvider filters = new SimpleFilterProvider().addFilter("SomeBeanFilter", filter); MappingJacksonValue mapping = new MappingJacksonValue(someBean); mapping.setFilters(filters); return mapping; }
Example 5
Source File: FilteringController.java From spring-web-services with MIT License | 3 votes |
@GetMapping("/filtering-list") public MappingJacksonValue retrieveListOfSomeBeans() { List<SomeBean> list = Arrays.asList(new SomeBean("value1", "value2", "value3"), new SomeBean("value12", "value22", "value32")); SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.filterOutAllExcept("field2", "field3"); FilterProvider filters = new SimpleFilterProvider().addFilter("SomeBeanFilter", filter); MappingJacksonValue mapping = new MappingJacksonValue(list); mapping.setFilters(filters); return mapping; }
Example 6
Source File: FilteringController.java From spring-microservices with MIT License | 3 votes |
@GetMapping("/filtering") public MappingJacksonValue retrieveSomeBean() { SomeBean someBean = new SomeBean("value1", "value2", "value3"); SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.filterOutAllExcept("field1", "field2"); FilterProvider filters = new SimpleFilterProvider().addFilter("SomeBeanFilter", filter); MappingJacksonValue mapping = new MappingJacksonValue(someBean); mapping.setFilters(filters); return mapping; }
Example 7
Source File: FilteringController.java From spring-microservices with MIT License | 3 votes |
@GetMapping("/filtering-list") public MappingJacksonValue retrieveListOfSomeBeans() { List<SomeBean> list = Arrays.asList(new SomeBean("value1", "value2", "value3"), new SomeBean("value12", "value22", "value32")); SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.filterOutAllExcept("field2", "field3"); FilterProvider filters = new SimpleFilterProvider().addFilter("SomeBeanFilter", filter); MappingJacksonValue mapping = new MappingJacksonValue(list); mapping.setFilters(filters); return mapping; }