Class PathFinder
java.lang.Object
software.amazon.smithy.model.selector.PathFinder
Finds the possible directed relationship paths from a starting shape to
shapes connected to the starting shape that match a selector.
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
An immutableRelationship
path from a starting shape to an end shape. -
Method Summary
Modifier and TypeMethodDescriptionstatic PathFinder
Creates aPathFinder
that uses the givenModel
.createPathToInputMember
(ToShapeId operationId, String memberName) Creates aPath
to an operation input member if it exists.createPathToOutputMember
(ToShapeId operationId, String memberName) Creates aPath
to an operation output member if it exists.void
relationshipFilter
(Predicate<Relationship> predicate) Sets a predicate function to prevents traversing specific relationships.Finds all of the possible paths from the starting shape to all shapes connected to the starting shape that match the given selector.search
(ToShapeId startingShape, Collection<Shape> targetShapes) Finds all of the possible paths from thestartingShape
to any of the provided shapes intargetShapes
.Finds all of the possible paths from the starting shape to all shapes connected to the starting shape that match the given selector.
-
Method Details
-
create
Creates aPathFinder
that uses the givenModel
.- Parameters:
model
- Model to search using aPathFinder
.- Returns:
- Returns the crated
PathFinder
.
-
relationshipFilter
Sets a predicate function to prevents traversing specific relationships.- Parameters:
predicate
- Predicate that must return true in order to continue traversing relationships.
-
search
Finds all of the possible paths from the starting shape to all shapes connected to the starting shape that match the given selector.- Parameters:
startingShape
- Starting shape to find the paths from.targetSelector
- Selector that matches shapes to find the path to.- Returns:
- Returns the list of matching paths.
-
search
Finds all of the possible paths from the starting shape to all shapes connected to the starting shape that match the given selector.- Parameters:
startingShape
- Starting shape to find the paths from.targetSelector
- Selector that matches shapes to find the path to.- Returns:
- Returns the list of matching paths.
-
search
Finds all of the possible paths from thestartingShape
to any of the provided shapes intargetShapes
.- Parameters:
startingShape
- Starting shape to find the paths from.targetShapes
- The shapes to try to find a path to.- Returns:
- Returns the list of matching paths.
-
createPathToInputMember
Creates aPath
to an operation input member if it exists.- Parameters:
operationId
- Operation to start from.memberName
- Input member name to find in the operation input.- Returns:
- Returns the optionally found
Path
to the member.
-
createPathToOutputMember
Creates aPath
to an operation output member if it exists.- Parameters:
operationId
- Operation to start from.memberName
- Output member name to find in the operation output.- Returns:
- Returns the optionally found
Path
to the member.
-