Class TopologicalShapeSort
- java.lang.Object
-
- software.amazon.smithy.model.loader.TopologicalShapeSort
-
public final class TopologicalShapeSort extends java.lang.Object
Topologically sorts shapes based on their dependencies (i.e., mixins).While this class is reusable, it is also stateful; shapes and edges are enqueued, and when sorted, all shapes and edges are dequeued.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TopologicalShapeSort.CycleException
Thrown when cycles exist between shapes.
-
Constructor Summary
Constructors Constructor Description TopologicalShapeSort()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<ShapeId>
dequeueSortedShapes()
Sort the shapes and returns the ordered list of shape IDs.void
enqueue(Shape shape)
Add a shape to the sort queue, and automatically extract dependencies.void
enqueue(ShapeId shape, java.util.Collection<ShapeId> dependencies)
Add a shape to the sort queue, and provide an explicit dependencies list.
-
-
-
Method Detail
-
enqueue
public void enqueue(Shape shape)
Add a shape to the sort queue, and automatically extract dependencies.- Parameters:
shape
- Shape to add.
-
enqueue
public void enqueue(ShapeId shape, java.util.Collection<ShapeId> dependencies)
Add a shape to the sort queue, and provide an explicit dependencies list.- Parameters:
shape
- Shape to add.dependencies
- Dependencies of the shape.
-
dequeueSortedShapes
public java.util.List<ShapeId> dequeueSortedShapes()
Sort the shapes and returns the ordered list of shape IDs.- Returns:
- Returns the topologically sorted list of shape IDs.
- Throws:
TopologicalShapeSort.CycleException
- if cycles exist between shapes.
-
-