@Test public void memberShape() { StringShape string = StringShape.builder() .id("ns.foo#String") .build(); MemberShape target = MemberShape.builder() .id("ns.foo#List$member") .target(string.getId()) .build(); ListShape list = ListShape.builder() .id("ns.foo#List") .member(target) .build(); Model model = Model.builder() .addShape(target) .addShape(string) .addShape(list) .build(); NeighborVisitor neighborVisitor = new NeighborVisitor(model); List<Relationship> relationships = target.accept(neighborVisitor); assertThat(relationships, containsInAnyOrder( Relationship.create(target, RelationshipType.MEMBER_CONTAINER, list), Relationship.create(target, RelationshipType.MEMBER_TARGET, string))); }
@Override public List<Relationship> memberShape(MemberShape shape) { List<Relationship> result = new ArrayList<>(); result.add(relationship(shape, RelationshipType.MEMBER_CONTAINER, shape.getContainer())); result.add(relationship(shape, RelationshipType.MEMBER_TARGET, shape.getTarget())); return result; }
NeighborVisitor extends ShapeVisitor.Default<List<Relationship>> implements NeighborProvider { @Override public List<Relationship> memberShape(MemberShape shape) { List<Relationship> result = new ArrayList<>(); result.add(relationship(shape, RelationshipType.MEMBER_CONTAINER, shape.getContainer())); result.add(relationship(shape, RelationshipType.MEMBER_TARGET, shape.getTarget())); return result; } }
NeighborVisitor extends ShapeVisitor.Default<List<Relationship>> implements NeighborProvider { @Override public List<Relationship> memberShape(MemberShape shape) { List<Relationship> result = new ArrayList<>(); result.add(relationship(shape, RelationshipType.MEMBER_CONTAINER, shape.getContainer())); result.add(relationship(shape, RelationshipType.MEMBER_TARGET, shape.getTarget())); return result; } NeighborVisitor(Model model); }
NeighborVisitor extends ShapeVisitor.Default<List<Relationship>> implements NeighborProvider { @Override public List<Relationship> memberShape(MemberShape shape) { List<Relationship> result = new ArrayList<>(); result.add(relationship(shape, RelationshipType.MEMBER_CONTAINER, shape.getContainer())); result.add(relationship(shape, RelationshipType.MEMBER_TARGET, shape.getTarget())); 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> memberShape(MemberShape shape) { List<Relationship> result = new ArrayList<>(); result.add(relationship(shape, RelationshipType.MEMBER_CONTAINER, shape.getContainer())); result.add(relationship(shape, RelationshipType.MEMBER_TARGET, shape.getTarget())); 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);  }