NeighborVisitor extends ShapeVisitor.Default<List<Relationship>> implements NeighborProvider { @Override public List<Relationship> listShape(ListShape shape) { return ListUtils.of(relationship(shape, RelationshipType.LIST_MEMBER, shape.getMember())); } NeighborVisitor(Model model); @Override List<Relationship> getNeighbors(Shape shape); @Override List<Relationship> getDefault(Shape shape); @Override List<Relationship> serviceShape(ServiceShape shape); @Override List<Relationship> resourceShape(ResourceShape shape); @Override List<Relationship> operationShape(OperationShape shape); @Override List<Relationship> memberShape(MemberShape shape); @Override List<Relationship> listShape(ListShape shape); @Override List<Relationship> setShape(SetShape shape); @Override List<Relationship> mapShape(MapShape shape); @Override List<Relationship> structureShape(StructureShape shape); @Override List<Relationship> unionShape(UnionShape shape);  }
@Test public void listShape() { Shape string = StringShape.builder().id("ns.foo#String").build(); ListShape list = ListShape.builder() .id("ns.foo#name") .member(string.getId()) .build(); Model model = Model.builder().addShape(list).addShape(string).build(); NeighborVisitor neighborVisitor = new NeighborVisitor(model); MemberShape memberTarget = list.getMember(); List<Relationship> relationships = list.accept(neighborVisitor); assertThat(relationships, contains(Relationship.create(list, RelationshipType.LIST_MEMBER, memberTarget))); }