public final class Walker
extends java.lang.Object
Any shape that is connected to another shape is "walked". A single shape can have multiple relationships to the same shape. For example, a resource can have both a "get" and a "child" relationship to an operation; however, the referenced operation will appear only once in the walker output.
Only shapes form a connected graph. Relationships created by traits are not traversed by the walker.
Constructor and Description |
---|
Walker(Model model) |
Walker(NeighborProvider provider) |
Modifier and Type | Method and Description |
---|---|
java.util.Iterator<Shape> |
iterateShapes(Shape shape)
Lazily iterates over all of the relationships in the closure of
the given shape, including the given shape.
|
java.util.Iterator<Shape> |
iterateShapes(Shape shape,
java.util.function.Predicate<Relationship> predicate)
Lazily iterates over all of the unique shapes in the closure of
the given shape, including the given shape.
|
java.util.Set<ShapeId> |
walkShapeIds(Shape shape)
Walks connected shapes in the model, returning their IDs in a set.
|
java.util.Set<ShapeId> |
walkShapeIds(Shape shape,
java.util.function.Predicate<Relationship> predicate)
Walks connected shapes in the model (including the given shape),
and returns a set of shape IDs.
|
java.util.Set<Shape> |
walkShapes(Shape shape)
Walks connected shapes in the model, returning them in a set.
|
java.util.Set<Shape> |
walkShapes(Shape shape,
java.util.function.Predicate<Relationship> predicate)
Walks connected shapes in the model (including the given shape),
and returns them in a set.
|
public Walker(Model model)
model
- Model to traverse.public Walker(NeighborProvider provider)
provider
- Neighbor provider used to traverse relationships.public java.util.Set<Shape> walkShapes(Shape shape)
shape
- The shape to start the traversal from.public java.util.Set<Shape> walkShapes(Shape shape, java.util.function.Predicate<Relationship> predicate)
shape
- The shape to start the traversal from.predicate
- Predicate used to prevent traversing relationships.public java.util.Set<ShapeId> walkShapeIds(Shape shape)
shape
- The shape to start the traversal from.public java.util.Set<ShapeId> walkShapeIds(Shape shape, java.util.function.Predicate<Relationship> predicate)
shape
- The shape to start the traversal from.predicate
- Predicate used to prevent traversing relationships.public java.util.Iterator<Shape> iterateShapes(Shape shape)
shape
- Shape to find the closure of.shape
.public java.util.Iterator<Shape> iterateShapes(Shape shape, java.util.function.Predicate<Relationship> predicate)
shape
- Shape to find the closure of.predicate
- Predicate used to short-circuit relationship branches.shape
.