本文整理匯總了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;
}