@Test public void updatesStructureContainerWhenMemberIsRemoved() { ShapeId stringShapeId = ShapeId.from("ns.foo#String"); StringShape string = StringShape.builder().id(stringShapeId).build(); MemberShape member1 = MemberShape.builder().id("ns.foo#Structure$member1").target("ns.foo#String").build(); MemberShape member2 = MemberShape.builder().id("ns.foo#Structure$member2").target("ns.foo#String").build(); MemberShape member3 = MemberShape.builder().id("ns.foo#Structure$member3").target("ns.foo#String").build(); StructureShape structure = StructureShape.builder() .id("ns.foo#Structure") .addMember(member1) .addMember(member2) .addMember(member3) .build(); Model model = Model.builder() .addShapes(string, structure, member1, member2, member3) .build(); Model result = ModelTransformer.create().filterShapes(model, shape -> { return !shape.getId().toString().equals("ns.foo#Structure$member2"); }); assertThat(result.getShape(member1.getId()), Matchers.equalTo(Optional.of(member1))); assertThat(result.getShape(member3.getId()), Matchers.equalTo(Optional.of(member3))); assertThat(result.getShape(member2.getId()), Matchers.is(Optional.empty())); assertThat(result.getShape(structure.getId()), Matchers.not(Optional.empty())); assertThat(result.getShape(structure.getId()).get().asStructureShape().get().getMember("member1"), Matchers.not(Optional.empty())); assertThat(result.getShape(structure.getId()).get().asStructureShape().get().getMember("member3"), Matchers.not(Optional.empty())); assertThat(result.getShape(structure.getId()).get().asStructureShape().get().getMember("member2"), Matchers.is(Optional.empty())); }
FilterShapes(Predicate<Shape> predicate) { this.predicate = predicate .or(shape -> Prelude.isPreludeShape(shape.getId())); }
FilterShapes { FilterShapes(Predicate<Shape> predicate) { this.predicate = predicate .or(shape -> Prelude.isPreludeShape(shape.getId())); } }
FilterShapes { FilterShapes(Predicate<Shape> predicate) { this.predicate = predicate .or(shape -> Prelude.isPreludeShape(shape.getId())); } FilterShapes(Predicate<Shape> predicate); }
FilterShapes { FilterShapes(Predicate<Shape> predicate) { this.predicate = predicate .or(shape -> Prelude.isPreludeShape(shape.getId())); } FilterShapes(Predicate<Shape> predicate);  }
FilterShapes { FilterShapes(Predicate<Shape> predicate) { this.predicate = predicate .or(shape -> Prelude.isPreludeShape(shape.getId())); } FilterShapes(Predicate<Shape> predicate);   }