@Test public void structureShape() { Shape memberShape1 = StringShape.builder().id("ns.foo#M1String").build(); Shape memberShape2 = StringShape.builder().id("ns.foo#M2String").build(); StructureShape struct = StructureShape.builder() .id("ns.foo#name") .addMember(MemberShape.builder() .id("ns.foo#name$m1") .target(memberShape1.getId()) .build()) .addMember(MemberShape.builder() .id("ns.foo#name$m2") .target(memberShape2.getId()) .build()) .build(); MemberShape member1Target = struct.getMember("m1").get(); MemberShape member2Target = struct.getMember("m2").get(); Model model = Model.builder() .addShape(struct) .addShape(memberShape1) .addShape(memberShape2) .addShape(member1Target) .addShape(member2Target) .build(); NeighborVisitor neighborVisitor = new NeighborVisitor(model); List<Relationship> relationships = struct.accept(neighborVisitor); assertThat(relationships, containsInAnyOrder( Relationship.create(struct, RelationshipType.STRUCTURE_MEMBER, member1Target), Relationship.create(struct, RelationshipType.STRUCTURE_MEMBER, member2Target))); }
@Override public List<Relationship> structureShape(StructureShape shape) { return shape.getAllMembers().values().stream() .map(member -> Relationship.create(shape, RelationshipType.STRUCTURE_MEMBER, member)) .collect(Collectors.toList()); }
NeighborVisitor extends ShapeVisitor.Default<List<Relationship>> implements NeighborProvider { @Override public List<Relationship> structureShape(StructureShape shape) { return shape.getAllMembers().values().stream() .map(member -> Relationship.create(shape, RelationshipType.STRUCTURE_MEMBER, member)) .collect(Collectors.toList()); } }
NeighborVisitor extends ShapeVisitor.Default<List<Relationship>> implements NeighborProvider { @Override public List<Relationship> structureShape(StructureShape shape) { return shape.getAllMembers().values().stream() .map(member -> Relationship.create(shape, RelationshipType.STRUCTURE_MEMBER, member)) .collect(Collectors.toList()); } NeighborVisitor(Model model); }
NeighborVisitor extends ShapeVisitor.Default<List<Relationship>> implements NeighborProvider { @Override public List<Relationship> structureShape(StructureShape shape) { return shape.getAllMembers().values().stream() .map(member -> Relationship.create(shape, RelationshipType.STRUCTURE_MEMBER, member)) .collect(Collectors.toList()); } 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); }
NeighborVisitor extends ShapeVisitor.Default<List<Relationship>> implements NeighborProvider { @Override public List<Relationship> structureShape(StructureShape shape) { return shape.getAllMembers().values().stream() .map(member -> Relationship.create(shape, RelationshipType.STRUCTURE_MEMBER, member)) .collect(Collectors.toList()); } 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);  }