@Test public void mapShape() { Shape key = StringShape.builder().id("ns.foo#KeyString").build(); Shape value = StringShape.builder().id("ns.foo#ValueString").build(); MapShape map = MapShape.builder() .id("ns.foo#name") .key(MemberShape.builder() .id("ns.foo#name$key") .target(key.getId()) .build()) .value(MemberShape.builder() .id("ns.foo#name$value") .target(value.getId()) .build()) .build(); MemberShape keyTarget = map.getKey(); MemberShape valueTarget = map.getValue(); Model model = Model.builder().addShape(map).addShape(key).addShape(value).build(); NeighborVisitor neighborVisitor = new NeighborVisitor(model); List<Relationship> relationships = map.accept(neighborVisitor); assertThat(relationships, containsInAnyOrder( Relationship.create(map, RelationshipType.MAP_KEY, keyTarget), Relationship.create(map, RelationshipType.MAP_VALUE, valueTarget))); }
@Override public List<Relationship> mapShape(MapShape shape) { List<Relationship> result = new ArrayList<>(); result.add(relationship(shape, RelationshipType.MAP_KEY, shape.getKey())); result.add(relationship(shape, RelationshipType.MAP_VALUE, shape.getValue())); return result; }
NeighborVisitor extends ShapeVisitor.Default<List<Relationship>> implements NeighborProvider { @Override public List<Relationship> mapShape(MapShape shape) { List<Relationship> result = new ArrayList<>(); result.add(relationship(shape, RelationshipType.MAP_KEY, shape.getKey())); result.add(relationship(shape, RelationshipType.MAP_VALUE, shape.getValue())); return result; } }
NeighborVisitor extends ShapeVisitor.Default<List<Relationship>> implements NeighborProvider { @Override public List<Relationship> mapShape(MapShape shape) { List<Relationship> result = new ArrayList<>(); result.add(relationship(shape, RelationshipType.MAP_KEY, shape.getKey())); result.add(relationship(shape, RelationshipType.MAP_VALUE, shape.getValue())); return result; } NeighborVisitor(Model model); }
NeighborVisitor extends ShapeVisitor.Default<List<Relationship>> implements NeighborProvider { @Override public List<Relationship> mapShape(MapShape shape) { List<Relationship> result = new ArrayList<>(); result.add(relationship(shape, RelationshipType.MAP_KEY, shape.getKey())); result.add(relationship(shape, RelationshipType.MAP_VALUE, shape.getValue())); return result; } 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> mapShape(MapShape shape) { List<Relationship> result = new ArrayList<>(); result.add(relationship(shape, RelationshipType.MAP_KEY, shape.getKey())); result.add(relationship(shape, RelationshipType.MAP_VALUE, shape.getValue())); return result; } 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);  }