Class ShapeIndex

  • All Implemented Interfaces:
    software.amazon.smithy.utils.ToSmithyBuilder<ShapeIndex>

    @Deprecated
    public final class ShapeIndex
    extends java.lang.Object
    implements software.amazon.smithy.utils.ToSmithyBuilder<ShapeIndex>
    Deprecated.
    Provides an index of Shapes in a Smithy model by ShapeId.

    The ShapeIndex represents a Smithy model in a flat graph-like index. Shapes reference other shapes by shape ID, and these shape IDs are used then matched with shapes in a ShapeIndex. Using this kind of graph-like structure rather than a something more like a tree allows for a fast iteration over all shapes in a model, allows for shapes to reference other shapes without requiring cyclic references, and maps cleanly to the mental model of a Smithy model definition (that is, shape IDs are used to connect shapes to other shapes, allow traits to be applied to shapes, and are used to suppress validation events). However, this does come with the trade-off that the ShapeIndex may be an an invalid state when it is accessed. As such, a ShapeIndex should be thoroughly validated before it is utilized.

    • Method Detail

      • toBuilder

        public ShapeIndex.Builder toBuilder()
        Deprecated.
        Specified by:
        toBuilder in interface software.amazon.smithy.utils.ToSmithyBuilder<ShapeIndex>
      • getShape

        public java.util.Optional<Shape> getShape​(ShapeId id)
        Deprecated.
        Attempts to retrieve a Shape by ShapeId.
        Parameters:
        id - Shape to retrieve by ID.
        Returns:
        Returns the optional shape.
      • shapes

        public java.util.stream.Stream<Shape> shapes()
        Deprecated.
        Gets a stream of Shapes in the index.
        Returns:
        Returns a stream of shapes.
      • shapes

        public <T extends Shape> java.util.stream.Stream<T> shapes​(java.lang.Class<T> shapeType)
        Deprecated.
        Gets a stream of shapes in the index of a specific type T.

        The provided shapeType class must exactly match the class of a shape in the shape index in order to be returned from this method; that is, the provided class must be a concrete subclass of Shape and not an abstract class like NumberShape.

        Type Parameters:
        T - Shape type to stream from the index.
        Parameters:
        shapeType - Shape type T to retrieve.
        Returns:
        A stream of shapes of T matching shapeType.
      • toSet

        public java.util.Set<Shape> toSet()
        Deprecated.
        Converts the ShapeIndex to an immutable Set of shapes.
        Returns:
        Returns an unmodifiable set of Shapes in the index.
      • hashCode

        public int hashCode()
        Deprecated.
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Deprecated.
        Overrides:
        equals in class java.lang.Object