Class UnstableFeatureIndex

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

public final class UnstableFeatureIndex extends Object implements KnowledgeIndex
Resolves the unstable feature a shape belongs to.

A shape carrying the unstable trait with a featureId is a feature owner. A shape belongs to an owner's feature when the owner encloses it.

  • Constructor Details

    • UnstableFeatureIndex

      public UnstableFeatureIndex(Model model)
  • Method Details

    • of

      public static UnstableFeatureIndex of(Model model)
    • getFeatureOwners

      public Set<ShapeId> getFeatureOwners(ShapeId shape)
      Gets the owners of the feature the given shape belongs to.

      An owner is a shape carrying unstable with a featureId, and an owner encloses itself. An empty result means the shape belongs to no feature. Exactly one owner means the shape belongs to that owner's feature. More than one owner means either the shape is shared between features or, when the shape is itself an owner, that it is nested within another feature.

      Parameters:
      shape - Shape to resolve.
      Returns:
      Returns the enclosing owners, or an empty set if the shape belongs to no feature.
    • getContainingServices

      public Set<ShapeId> getContainingServices(ShapeId owner)
      Gets the services the given feature owner resides in.

      An owner that is itself a service resides in itself. This is only populated for owners, since a feature id is resolved against the unstableFeatures trait of the services its owner resides in. An owner nested inside another feature still reports the services it resides in.

      Parameters:
      owner - Feature owner to resolve.
      Returns:
      Returns the services the owner resides in, or an empty set if it is bound to no service.
    • getFeature

      Gets the metadata of the feature the given shape belongs to.

      The result is empty unless the shape belongs to exactly one feature whose id resolves to a single unstableFeatures entry, so an ambiguous model resolves to no feature rather than to an arbitrary one of the candidates.

      Parameters:
      shape - Shape to resolve.
      Returns:
      Returns the feature metadata, or empty if it does not resolve.
    • isInPreviewClosure

      public boolean isInPreviewClosure(ShapeId shape)
      Returns whether the given shape belongs to a feature that is in preview.
      Parameters:
      shape - Shape to check.
      Returns:
      True if the shape is owned and all of its owners are PREVIEW features.