in smithy-model/src/main/java/software/amazon/smithy/model/selector/TopDownSelector.java [49:84]
private boolean pushMatch(boolean qualified, Context context, Shape shape, Receiver next, Set<ShapeId> visited) {
if (visited.contains(shape.getId())) {
return true;
}
visited.add(shape.getId());
// If the flag isn't set, then check if this shape sets it to true.
if (!qualified && context.receivedShapes(shape, qualifier)) {
qualified = true;
}
// If the flag is set, then check if any predicates unset it.
if (qualified && disqualifier != null && context.receivedShapes(shape, disqualifier)) {
qualified = false;
}
// If the shape is matched, then it's sent to the next receiver.
if (qualified && !next.apply(context, shape)) {
return false; // fast-fail if the receiver fast-fails.
}
// Recursively check each nested resource/operation.
for (Relationship rel : context.neighborIndex.getProvider().getNeighbors(shape)) {
if (rel.getNeighborShape().isPresent() && !rel.getNeighborShapeId().equals(shape.getId())) {
if (rel.getRelationshipType() == RelationshipType.RESOURCE
|| rel.getRelationshipType() == RelationshipType.OPERATION) {
if (!pushMatch(qualified, context, rel.getNeighborShape().get(), next, visited)) {
return false;
}
}
}
}
return true;
}