public final class PathFinder
extends java.lang.Object
For example, the PathFinder
can answer the question of
"Where are all of the shapes in the closure of the input of an operation
marked with the sensitive
trait?"
PathFinder pathFinder = PathFinder.create(myModel);
List<PathFinder.Path> results = pathFinder.search(myOperationInput, "[trait|sensitive]");
PathFinder
is directed, meaning it only traverses relationships
from shapes that define a relationship to shapes that it targets. In other
words, PathFinder
will not traverse relationships from a resource to
the resource's parent or from a member to the shape that contains it
because those are inverted relationships.
Modifier and Type | Class and Description |
---|---|
static class |
PathFinder.Path
An immutable
Relationship path from a starting shape to an end shape. |
Modifier and Type | Method and Description |
---|---|
static PathFinder |
create(Model model)
Creates a
PathFinder that uses the given Model . |
java.util.Optional<PathFinder.Path> |
createPathToInputMember(ToShapeId operationId,
java.lang.String memberName)
Creates a
Path to an operation input member if it exists. |
java.util.Optional<PathFinder.Path> |
createPathToOutputMember(ToShapeId operationId,
java.lang.String memberName)
Creates a
Path to an operation output member if it exists. |
java.util.List<PathFinder.Path> |
search(ToShapeId startingShape,
java.util.Collection<Shape> targetShapes)
Finds all of the possible paths from the
startingShape to
any of the provided shapes in targetShapes . |
java.util.List<PathFinder.Path> |
search(ToShapeId startingShape,
Selector targetSelector)
Finds all of the possible paths from the starting shape to all shapes
connected to the starting shape that match the given selector.
|
java.util.List<PathFinder.Path> |
search(ToShapeId startingShape,
java.lang.String targetSelector)
Finds all of the possible paths from the starting shape to all shapes
connected to the starting shape that match the given selector.
|
public static PathFinder create(Model model)
PathFinder
that uses the given Model
.model
- Model to search using a PathFinder
.PathFinder
.public java.util.List<PathFinder.Path> search(ToShapeId startingShape, java.lang.String targetSelector)
startingShape
- Starting shape to find the paths from.targetSelector
- Selector that matches shapes to find the path to.public java.util.List<PathFinder.Path> search(ToShapeId startingShape, Selector targetSelector)
startingShape
- Starting shape to find the paths from.targetSelector
- Selector that matches shapes to find the path to.public java.util.List<PathFinder.Path> search(ToShapeId startingShape, java.util.Collection<Shape> targetShapes)
startingShape
to
any of the provided shapes in targetShapes
.startingShape
- Starting shape to find the paths from.targetShapes
- The shapes to try to find a path to.public java.util.Optional<PathFinder.Path> createPathToInputMember(ToShapeId operationId, java.lang.String memberName)
Path
to an operation input member if it exists.operationId
- Operation to start from.memberName
- Input member name to find in the operation input.Path
to the member.public java.util.Optional<PathFinder.Path> createPathToOutputMember(ToShapeId operationId, java.lang.String memberName)
Path
to an operation output member if it exists.operationId
- Operation to start from.memberName
- Output member name to find in the operation output.Path
to the member.