• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PropertyFilter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.fasterxml.jackson.databind.ser.PropertyFilter的典型用法代码示例。如果您正苦于以下问题:Java PropertyFilter类的具体用法?Java PropertyFilter怎么用?Java PropertyFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PropertyFilter类属于com.fasterxml.jackson.databind.ser包,在下文中一共展示了PropertyFilter类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: test

import com.fasterxml.jackson.databind.ser.PropertyFilter; //导入依赖的package包/类
@Test
public void test() throws Exception {
  SomeObject someObject = new SomeObject(1, 2, 3);
  PropertyFilter withoutB = SimpleBeanPropertyFilter.serializeAllExcept("b");

  String actual = mapper.writeValueAsString(someObject);
  Assert.assertEquals(1, parser.parse(actual).read("$.a", Integer.class).intValue());
  Assert.assertEquals(2, parser.parse(actual).read("$.b", Integer.class).intValue());
  Assert.assertEquals(3, parser.parse(actual).read("$.c", Integer.class).intValue());

  actual = mapper.writer(new DynamicFilterProvider(withoutB)).writeValueAsString(someObject);
  Assert.assertEquals(1, parser.parse(actual).read("$.a", Integer.class).intValue());
  Assert.assertNull(parser.parse(actual).read("$.b"));
  Assert.assertEquals(3, parser.parse(actual).read("$.c", Integer.class).intValue());

  actual = mapper.writeValueAsString(someObject);
  Assert.assertEquals(1, parser.parse(actual).read("$.a", Integer.class).intValue());
  Assert.assertEquals(2, parser.parse(actual).read("$.b", Integer.class).intValue());
  Assert.assertEquals(3, parser.parse(actual).read("$.c", Integer.class).intValue());

  actual = mapper.writer(new DynamicFilterProvider()).writeValueAsString(someObject);
  Assert.assertEquals(1, parser.parse(actual).read("$.a", Integer.class).intValue());
  Assert.assertEquals(2, parser.parse(actual).read("$.b", Integer.class).intValue());
  Assert.assertEquals(3, parser.parse(actual).read("$.c", Integer.class).intValue());
}
 
开发者ID:shihyuho,项目名称:jackson-dynamic-filter,代码行数:26,代码来源:DynamicFilterProviderTest.java


示例2: propertyFilterResponseBodyAdvice

import com.fasterxml.jackson.databind.ser.PropertyFilter; //导入依赖的package包/类
@Bean
public DynamicFilterResponseBodyAdvice propertyFilterResponseBodyAdvice() {
  DynamicFilterResponseBodyAdvice advice = new DynamicFilterResponseBodyAdvice();
  advice.addResolvers(new DynamicFilterResolver<WithoutAB>() {
    @Override
    public PropertyFilter apply(WithoutAB t) {
      return SimpleBeanPropertyFilter.serializeAllExcept("a", "b");
    }
  });
  return advice;
}
 
开发者ID:shihyuho,项目名称:jackson-dynamic-filter,代码行数:12,代码来源:DynamicFilterResolverTest.java


示例3: findPropertyFilter

import com.fasterxml.jackson.databind.ser.PropertyFilter; //导入依赖的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();
}
 
开发者ID:icode,项目名称:ameba,代码行数:35,代码来源:JacksonObjectProvider.java


示例4: assertConfiguredWithMatcher

import com.fasterxml.jackson.databind.ser.PropertyFilter; //导入依赖的package包/类
private void assertConfiguredWithMatcher(ObjectMapper mapper, Matcher matcher) {
  AnnotationIntrospector introspector = mapper.getSerializationConfig().getAnnotationIntrospector();
  Object filterId = introspector.findFilterId((Annotated) AnnotatedClass.construct(
      TestObject.class, introspector, mapper.getDeserializationConfig()));
  assertNotNull(filterId);

  PropertyFilter propertyFilter =
      mapper.getSerializationConfig().getFilterProvider().findPropertyFilter(filterId, new TestObject());
  assertNotNull(propertyFilter);
  assertTrue(propertyFilter instanceof JacksonMatcherFilter);
  assertEquals(matcher, ((JacksonMatcherFilter) propertyFilter).getMatcher());
}
 
开发者ID:PressAssociation,项目名称:partial-response,代码行数:13,代码来源:JacksonRequestParamFilterTest.java


示例5: resolveFilter

import com.fasterxml.jackson.databind.ser.PropertyFilter; //导入依赖的package包/类
protected Optional<PropertyFilter> resolveFilter(MethodParameter returnType) {
  return resolvers.values().stream().map(resolver -> resolver.resolve(returnType))
      .filter(Objects::nonNull).findFirst();
}
 
开发者ID:shihyuho,项目名称:jackson-dynamic-filter,代码行数:5,代码来源:DynamicFilterResponseBodyAdvice.java


示例6: apply

import com.fasterxml.jackson.databind.ser.PropertyFilter; //导入依赖的package包/类
@Override
public PropertyFilter apply(SerializeAllExcept annotation) {
  return SimpleBeanPropertyFilter.serializeAllExcept(annotation.value());
}
 
开发者ID:shihyuho,项目名称:jackson-dynamic-filter,代码行数:5,代码来源:SerializeAllExceptResolver.java


示例7: apply

import com.fasterxml.jackson.databind.ser.PropertyFilter; //导入依赖的package包/类
@Override
public PropertyFilter apply(FilterOutAllExcept annotation) {
  return SimpleBeanPropertyFilter.filterOutAllExcept(annotation.value());
}
 
开发者ID:shihyuho,项目名称:jackson-dynamic-filter,代码行数:5,代码来源:FilterOutAllExceptResolver.java


示例8: resolve

import com.fasterxml.jackson.databind.ser.PropertyFilter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public final PropertyFilter resolve(MethodParameter methodParameter) {
  return Optional.ofNullable(methodParameter.getMethodAnnotation((Class<A>) getType()))
      .map(this::apply).orElse(null);
}
 
开发者ID:shihyuho,项目名称:jackson-dynamic-filter,代码行数:6,代码来源:DynamicFilterResolver.java


示例9: apply

import com.fasterxml.jackson.databind.ser.PropertyFilter; //导入依赖的package包/类
@Override
public PropertyFilter apply(WithoutAB t) {
  return null;
}
 
开发者ID:shihyuho,项目名称:jackson-dynamic-filter,代码行数:5,代码来源:DynamicFilterResponseBodyAdviceTest.java


示例10: registerFilterProvider

import com.fasterxml.jackson.databind.ser.PropertyFilter; //导入依赖的package包/类
private void registerFilterProvider() {
    PropertyFilter apiMembershipTypeFilter = new ApiPermissionFilter();
    mapper.setFilterProvider(new SimpleFilterProvider(Collections.singletonMap("apiMembershipTypeFilter", apiMembershipTypeFilter)));
}
 
开发者ID:gravitee-io,项目名称:gravitee-management-rest-api,代码行数:5,代码来源:ObjectMapperResolver.java


示例11: setUp

import com.fasterxml.jackson.databind.ser.PropertyFilter; //导入依赖的package包/类
@Before
public void setUp() {
    PropertyFilter apiMembershipTypeFilter = new ApiPermissionFilter();
    objectMapper.setFilterProvider(new SimpleFilterProvider(Collections.singletonMap("apiMembershipTypeFilter", apiMembershipTypeFilter)));
}
 
开发者ID:gravitee-io,项目名称:gravitee-management-rest-api,代码行数:6,代码来源:ApiService_FindByUserTest.java


示例12: setUp

import com.fasterxml.jackson.databind.ser.PropertyFilter; //导入依赖的package包/类
@Before
public void setUp() throws TechnicalException {
    PropertyFilter apiMembershipTypeFilter = new ApiPermissionFilter();
    objectMapper.setFilterProvider(new SimpleFilterProvider(Collections.singletonMap("apiMembershipTypeFilter", apiMembershipTypeFilter)));

    Api api = new Api();
    api.setId(API_ID);
    api.setDescription("Gravitee.io");
    when(apiRepository.findById(API_ID)).thenReturn(Optional.of(api));
    PageEntity page = new PageEntity();
    page.setName("My Title");
    page.setOrder(1);
    page.setType(PageType.MARKDOWN.toString());
    page.setContent("Read the doc");
    when(pageService.findApiPagesByApi(API_ID)).thenReturn(Collections.singletonList(new PageListItem()));
    when(pageService.findById(any())).thenReturn(page);
    Membership membership = new Membership();
    membership.setUserId("johndoe");
    membership.setReferenceId(API_ID);
    membership.setReferenceType(MembershipReferenceType.API);
    membership.setRoles(Collections.singletonMap(RoleScope.API.getId(), SystemRole.PRIMARY_OWNER.name()));
    when(membershipRepository.findByReferenceAndRole(eq(MembershipReferenceType.API), eq(API_ID), any(), any()))
            .thenReturn(Collections.singleton(membership));
    MemberEntity memberEntity = new MemberEntity();
    memberEntity.setUsername(membership.getUserId());
    memberEntity.setRole(SystemRole.PRIMARY_OWNER.name());
    when(membershipService.getMembers(eq(MembershipReferenceType.API), eq(API_ID), eq(RoleScope.API)))
            .thenReturn(Collections.singleton(memberEntity));
    UserEntity userEntity = new UserEntity();
    userEntity.setUsername(memberEntity.getUsername());
    when(userService.findByName(memberEntity.getUsername(), false)).thenReturn(userEntity);

    api.setGroups(Collections.singleton("my-group"));
    GroupEntity groupEntity = new GroupEntity();
    groupEntity.setId("my-group");
    groupEntity.setName("My Group");
    when(groupService.findByIds(api.getGroups())).thenReturn(Collections.singleton(groupEntity));

    PlanEntity publishedPlan = new PlanEntity();
    publishedPlan.setId("plan-id");
    publishedPlan.setApis(Collections.singleton(API_ID));
    publishedPlan.setDescription("free plan");
    publishedPlan.setType(PlanType.API);
    publishedPlan.setSecurity(PlanSecurityType.API_KEY);
    publishedPlan.setValidation(PlanValidationType.AUTO);
    publishedPlan.setStatus(PlanStatus.PUBLISHED);
    Map<String, Path> paths = new HashMap<>();
    Path path = new Path();
    path.setPath("/");
    io.gravitee.definition.model.Rule rule = new io.gravitee.definition.model.Rule();
    rule.setEnabled(true);
    rule.setMethods(Collections.singletonList(HttpMethod.GET));
    Policy policy = new Policy();
    policy.setName("rate-limit");
    String ls = System.lineSeparator();
    policy.setConfiguration("{" + ls +
            "          \"rate\": {" + ls +
            "            \"limit\": 1," + ls +
            "            \"periodTime\": 1," + ls +
            "            \"periodTimeUnit\": \"SECONDS\"" + ls +
            "          }" + ls +
            "        }");
    rule.setPolicy(policy);
    path.setRules(Collections.singletonList(rule));
    paths.put("/", path);
    publishedPlan.setPaths(paths);
    PlanEntity closedPlan = new PlanEntity();
    closedPlan.setId("closedPlan-id");
    closedPlan.setApis(Collections.singleton(API_ID));
    closedPlan.setDescription("free closedPlan");
    closedPlan.setType(PlanType.API);
    closedPlan.setSecurity(PlanSecurityType.API_KEY);
    closedPlan.setValidation(PlanValidationType.AUTO);
    closedPlan.setStatus(PlanStatus.CLOSED);
    closedPlan.setPaths(paths);
    Set<PlanEntity> set = new HashSet<>();
    set.add(publishedPlan);
    set.add(closedPlan);
    when(planService.findByApi(API_ID)).thenReturn(set);
}
 
开发者ID:gravitee-io,项目名称:gravitee-management-rest-api,代码行数:81,代码来源:ApiService_ExportAsJsonTest.java


示例13: defaultFiler

import com.fasterxml.jackson.databind.ser.PropertyFilter; //导入依赖的package包/类
public JsonMapper defaultFiler(PropertyFilter bpf){
//		this.filterProvider.setDefaultFilter(bpf);
		this.filterProvider.setDefaultFilter(bpf);
		return this;
	}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:6,代码来源:JsonMapper.java


示例14: DynamicFilterProvider

import com.fasterxml.jackson.databind.ser.PropertyFilter; //导入依赖的package包/类
/**
 * Construct a {@code PropertyFilterHolder} for given {@code delegate}
 * 
 * @param delegate PropertyFilter
 * @throws NullPointerException if {@code delegate} is {@code null}
 */
public DynamicFilterProvider(PropertyFilter delegate) {
  this.delegate = requireNonNull(delegate);
  addFilter(FILTER_ID, this);
}
 
开发者ID:shihyuho,项目名称:jackson-dynamic-filter,代码行数:11,代码来源:DynamicFilterProvider.java



注:本文中的com.fasterxml.jackson.databind.ser.PropertyFilter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CometProcessor类代码示例发布时间:2022-05-22
下一篇:
Java SequenceModifier类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap