Class ShapeClosureIndex

java.lang.Object
software.amazon.smithy.model.knowledge.ShapeClosureIndex
All Implemented Interfaces:
KnowledgeIndex

public final class ShapeClosureIndex extends Object implements KnowledgeIndex
Resolves shapeClosures metadata into the set of shapes that make up each declared closure.

A closure starts from the shapes that match its includeNamespaces and includeBySelector criteria and is expanded transitively through directed neighbor relationships. The resolved set may therefore contain member shapes and any prelude shapes reached by walking those neighbors (e.g. smithy.api#String via a structure member).

The rename member of a closure is also exposed so consumers can apply the renames consistently.

  • Constructor Details

    • ShapeClosureIndex

      public ShapeClosureIndex(Model model)
  • Method Details

    • of

      public static ShapeClosureIndex of(Model model)
    • getShapesInClosure

      public Set<Shape> getShapesInClosure(String closure)
      Gets the shapes in the named closure, including any prelude shapes that were reached by transitive walking.
      Parameters:
      closure - The id of the closure to look up.
      Returns:
      The shapes in the closure.
      Throws:
      ExpectationNotMetException - if no closure with the given id is defined in the model.
    • getRootShapesInClosure

      public Set<Shape> getRootShapesInClosure(String closure)
      Gets the root shapes in the named closure.

      This only includes shapes directly matched by includeBySelector and shape that are part of a namespace in includeNamespaces. It does NOT include any connected shapes that are not themselves matched by the selector or part of an included namespace.

      Parameters:
      closure - The id of the closure to look up.
      Returns:
      The shapes in the closure.
      Throws:
      ExpectationNotMetException - if no closure with the given id is defined in the model.
    • getRenames

      public Map<ShapeId,String> getRenames(String closure)
      Gets the renames declared by the named closure.

      The keys are the original shape ids and the values are the new names (without a namespace) that consumers should use for those shapes.

      Parameters:
      closure - The id of the closure to look up.
      Returns:
      The renames declared by the closure.
      Throws:
      ExpectationNotMetException - if no closure with the given id is defined in the model.
    • getClosureIds

      public Set<String> getClosureIds()
      Returns:
      The ids of every closure declared in the model.