@Test public void doesNotCheckPrelude() { Model model = Model.assembler().assemble().unwrap(); assertThat(new UnreferencedShapes().compute(model), empty()); }
public Set<Shape> compute(Model model) { Walker shapeWalker = new Walker(NeighborProviderIndex.of(model).getProvider()); Set<Shape> connected = model.shapes(ServiceShape.class) .flatMap(service -> shapeWalker.walkShapes(service).stream()) .collect(Collectors.toSet()); model.shapes() .filter(shape -> shape.hasTrait(TraitDefinition.class)) .flatMap(shape -> shapeWalker.walkShapes(shape).stream()) .forEach(connected::add); return model.shapes() .filter(FunctionalUtils.not(Shape::isMemberShape)) .filter(FunctionalUtils.not(connected::contains)) .filter(FunctionalUtils.not(Prelude::isPreludeShape)) .filter(keepFilter) .collect(Collectors.toSet()); }
UnreferencedShapes { public Set<Shape> compute(Model model) { Walker shapeWalker = new Walker(NeighborProviderIndex.of(model).getProvider()); Set<Shape> connected = model.shapes(ServiceShape.class) .flatMap(service -> shapeWalker.walkShapes(service).stream()) .collect(Collectors.toSet()); model.shapes() .filter(shape -> shape.hasTrait(TraitDefinition.class)) .flatMap(shape -> shapeWalker.walkShapes(shape).stream()) .forEach(connected::add); return model.shapes() .filter(FunctionalUtils.not(Shape::isMemberShape)) .filter(FunctionalUtils.not(connected::contains)) .filter(FunctionalUtils.not(Prelude::isPreludeShape)) .filter(keepFilter) .collect(Collectors.toSet()); } }
UnreferencedShapes { public Set<Shape> compute(Model model) { Walker shapeWalker = new Walker(NeighborProviderIndex.of(model).getProvider()); Set<Shape> connected = model.shapes(ServiceShape.class) .flatMap(service -> shapeWalker.walkShapes(service).stream()) .collect(Collectors.toSet()); model.shapes() .filter(shape -> shape.hasTrait(TraitDefinition.class)) .flatMap(shape -> shapeWalker.walkShapes(shape).stream()) .forEach(connected::add); return model.shapes() .filter(FunctionalUtils.not(Shape::isMemberShape)) .filter(FunctionalUtils.not(connected::contains)) .filter(FunctionalUtils.not(Prelude::isPreludeShape)) .filter(keepFilter) .collect(Collectors.toSet()); } UnreferencedShapes();  UnreferencedShapes(Predicate<Shape> keepFilter); }
UnreferencedShapes { public Set<Shape> compute(Model model) { Walker shapeWalker = new Walker(NeighborProviderIndex.of(model).getProvider()); Set<Shape> connected = model.shapes(ServiceShape.class) .flatMap(service -> shapeWalker.walkShapes(service).stream()) .collect(Collectors.toSet()); model.shapes() .filter(shape -> shape.hasTrait(TraitDefinition.class)) .flatMap(shape -> shapeWalker.walkShapes(shape).stream()) .forEach(connected::add); return model.shapes() .filter(FunctionalUtils.not(Shape::isMemberShape)) .filter(FunctionalUtils.not(connected::contains)) .filter(FunctionalUtils.not(Prelude::isPreludeShape)) .filter(keepFilter) .collect(Collectors.toSet()); } UnreferencedShapes();  UnreferencedShapes(Predicate<Shape> keepFilter); Set<Shape> compute(Model model); }
UnreferencedShapes { public Set<Shape> compute(Model model) { Walker shapeWalker = new Walker(NeighborProviderIndex.of(model).getProvider()); Set<Shape> connected = model.shapes(ServiceShape.class) .flatMap(service -> shapeWalker.walkShapes(service).stream()) .collect(Collectors.toSet()); model.shapes() .filter(shape -> shape.hasTrait(TraitDefinition.class)) .flatMap(shape -> shapeWalker.walkShapes(shape).stream()) .forEach(connected::add); return model.shapes() .filter(FunctionalUtils.not(Shape::isMemberShape)) .filter(FunctionalUtils.not(connected::contains)) .filter(FunctionalUtils.not(Prelude::isPreludeShape)) .filter(keepFilter) .collect(Collectors.toSet()); } UnreferencedShapes();  UnreferencedShapes(Predicate<Shape> keepFilter); Set<Shape> compute(Model model);  }