Class Prelude


  • public final class Prelude
    extends java.lang.Object
    Represents the prelude model available to every Smithy model.

    The prelude consists of public prelude shapes like smithy.api#String and traits that are available to all models like box and required.

    A key design requirement of the prelude is that it cannot require a loaded prelude model in order to reason about the prelude as this would result in infinite recursion while loading the prelude model.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String NAMESPACE
      The Smithy prelude namespace.
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static boolean isPreludeShape​(ToShapeId id)
      Checks if the given shape ID is defined by the prelude.
      static boolean isPublicPreludeShape​(ToShapeId id)
      Checks if the given shape is a public shape or trait defined by the prelude.
      static java.util.Optional<Shape> resolveShapeId​(Model model, java.lang.String fromNamespace, java.lang.String target)
      Returns the resolved shape of a shape target by first checking if a shape in the namespace relative to the target matches the given name, and then by checking if a public prelude shape matches the given name.
      static java.util.Optional<Shape> resolveShapeId​(ShapeIndex index, java.lang.String fromNamespace, java.lang.String target)
      Deprecated.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NAMESPACE

        public static final java.lang.String NAMESPACE
        The Smithy prelude namespace.
        See Also:
        Constant Field Values
    • Method Detail

      • isPreludeShape

        public static boolean isPreludeShape​(ToShapeId id)
        Checks if the given shape ID is defined by the prelude.

        Specifically, this checks if the namespace of the provided shape ID is equal to smithy.api.

        Parameters:
        id - Shape ID to check.
        Returns:
        Returns true if the shape is a prelude shape.
      • isPublicPreludeShape

        public static boolean isPublicPreludeShape​(ToShapeId id)
        Checks if the given shape is a public shape or trait defined by the prelude.
        Parameters:
        id - Shape to check.
        Returns:
        Returns true if the shape is a public prelude shape.
      • resolveShapeId

        @Deprecated
        public static java.util.Optional<Shape> resolveShapeId​(ShapeIndex index,
                                                               java.lang.String fromNamespace,
                                                               java.lang.String target)
        Deprecated.
      • resolveShapeId

        public static java.util.Optional<Shape> resolveShapeId​(Model model,
                                                               java.lang.String fromNamespace,
                                                               java.lang.String target)
        Returns the resolved shape of a shape target by first checking if a shape in the namespace relative to the target matches the given name, and then by checking if a public prelude shape matches the given name.
        Parameters:
        model - Model to resolve against.
        fromNamespace - Namespace the target was defined in.
        target - The shape target (e.g., "foo", "smithy.api#String", etc.).
        Returns:
        Returns the optionally resolved shape.
        Throws:
        ShapeIdSyntaxException - if the target or namespace is invalid.