本文整理汇总了Java中com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter.filterOutAllExcept方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleBeanPropertyFilter.filterOutAllExcept方法的具体用法?Java SimpleBeanPropertyFilter.filterOutAllExcept怎么用?Java SimpleBeanPropertyFilter.filterOutAllExcept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter
的用法示例。
在下文中一共展示了SimpleBeanPropertyFilter.filterOutAllExcept方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; //导入方法依赖的package包/类
@Override
public PropertyFilter apply(FilterOutAllExcept annotation) {
return SimpleBeanPropertyFilter.filterOutAllExcept(annotation.value());
}
示例2: findPropertyFilter
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; //导入方法依赖的package包/类
@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();
}
示例3: include
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; //导入方法依赖的package包/类
/**
* 包含指定的属性
*/
public Jacksons include(Class<?> dataType, String... properties) {
SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.filterOutAllExcept(properties);
return definePropertyFilter(dataType, filter);
}
示例4: retrieveSomeBean
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; //导入方法依赖的package包/类
@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;
}
示例5: retrieveListOfSomeBeans
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; //导入方法依赖的package包/类
@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;
}