Class PathFinder
- java.lang.Object
-
- software.amazon.smithy.model.selector.PathFinder
-
public final class PathFinder extends java.lang.ObjectFinds the possible directed relationship paths from a starting shape to shapes connected to the starting shape that match a selector.For example, the
PathFindercan answer the question of "Where are all of the shapes in the closure of the input of an operation marked with thesensitivetrait?"PathFinder pathFinder = PathFinder.create(myModel); List<PathFinder.Path> results = pathFinder.search(myOperationInput, "[trait|sensitive]");PathFinderis directed, meaning it only traverses relationships from shapes that define a relationship to shapes that it targets. In other words,PathFinderwill 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
Nested Classes Modifier and Type Class Description static classPathFinder.PathAn immutableRelationshippath from a starting shape to an end shape.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PathFindercreate(Model model)Creates aPathFinderthat uses the givenModel.java.util.Optional<PathFinder.Path>createPathToInputMember(ToShapeId operationId, java.lang.String memberName)Creates aPathto an operation input member if it exists.java.util.Optional<PathFinder.Path>createPathToOutputMember(ToShapeId operationId, java.lang.String memberName)Creates aPathto an operation output member if it exists.voidrelationshipFilter(java.util.function.Predicate<Relationship> predicate)Sets a predicate function to prevents traversing specific relationships.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.java.util.List<PathFinder.Path>search(ToShapeId startingShape, java.util.Collection<Shape> targetShapes)Finds all of the possible paths from thestartingShapeto any of the provided shapes intargetShapes.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.
-
-
-
Method Detail
-
create
public static PathFinder create(Model model)
Creates aPathFinderthat uses the givenModel.- Parameters:
model- Model to search using aPathFinder.- Returns:
- Returns the crated
PathFinder.
-
relationshipFilter
public void relationshipFilter(java.util.function.Predicate<Relationship> predicate)
Sets a predicate function to prevents traversing specific relationships.- Parameters:
predicate- Predicate that must return true in order to continue traversing relationships.
-
search
public 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.- 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
public 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.- 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
public java.util.List<PathFinder.Path> search(ToShapeId startingShape, java.util.Collection<Shape> targetShapes)
Finds all of the possible paths from thestartingShapeto 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
public java.util.Optional<PathFinder.Path> createPathToInputMember(ToShapeId operationId, java.lang.String memberName)
Creates aPathto 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
Pathto the member.
-
createPathToOutputMember
public java.util.Optional<PathFinder.Path> createPathToOutputMember(ToShapeId operationId, java.lang.String memberName)
Creates aPathto 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
Pathto the member.
-
-