Class Shape

    • Method Detail

      • shapeToBuilder

        public static <B extends AbstractShapeBuilder<B,​S>,​S extends Shape> B shapeToBuilder​(S shape)
        Converts a shape, potentially of an unknown concrete type, into a Shape builder.
        Type Parameters:
        B - Shape builder to create.
        S - Shape that is being converted to a builder.
        Parameters:
        shape - Shape to create a builder from.
        Returns:
        Returns a shape fro the given shape.
      • getType

        public final ShapeType getType()
        Gets the type of the shape.
        Returns:
        Returns the type;
      • accept

        public abstract <R> R accept​(ShapeVisitor<R> cases)
        Dispatches the shape to the appropriate ShapeVisitor method.
        Type Parameters:
        R - Return type of the accept.
        Parameters:
        cases - NeighborVisitor to use.
        Returns:
        Returns the result.
      • getId

        public final ShapeId getId()
        Get the ShapeId of the shape.
        Returns:
        Returns the shape ID.
      • hasTrait

        public boolean hasTrait​(java.lang.String id)
        Checks if the shape has a specific trait by name.

        Relative shape IDs are assumed to refer to the "smithy.api" namespace.

        Parameters:
        id - The possibly relative trait ID.
        Returns:
        Returns true if the shape has the given trait.
      • hasTrait

        public boolean hasTrait​(ShapeId id)
        Checks if the shape has a specific trait by name.
        Parameters:
        id - The fully-qualified trait ID.
        Returns:
        Returns true if the shape has the given trait.
      • hasTrait

        public boolean hasTrait​(java.lang.Class<? extends Trait> traitClass)
        Checks if the shape has a specific trait by class.
        Parameters:
        traitClass - Trait class to check.
        Returns:
        Returns true if the shape has the given trait.
      • findTrait

        public java.util.Optional<Trait> findTrait​(ShapeId id)
        Attempts to find a trait applied to the shape by name.
        Parameters:
        id - The trait shape ID.
        Returns:
        Returns the optionally found trait.
      • findTrait

        public java.util.Optional<Trait> findTrait​(java.lang.String id)
        Attempts to find a trait applied to the shape by ID.

        Relative shape IDs are assumed to refer to the "smithy.api" namespace.

        Parameters:
        id - The trait ID.
        Returns:
        Returns the optionally found trait.
      • getTrait

        public final <T extends Trait> java.util.Optional<T> getTrait​(java.lang.Class<T> traitClass)
        Attempt to retrieve a specific Trait by class from the shape.

        The first trait instance found matching the given type is returned.

        Type Parameters:
        T - The instance of the trait to retrieve.
        Parameters:
        traitClass - Trait class to retrieve.
        Returns:
        Returns the matching trait.
      • expectTrait

        public final <T extends Trait> T expectTrait​(java.lang.Class<T> traitClass)
        Gets specific Trait by class from the shape or throws if not found.
        Type Parameters:
        T - The instance of the trait to retrieve.
        Parameters:
        traitClass - Trait class to retrieve.
        Returns:
        Returns the matching trait.
        Throws:
        ExpectationNotMetException - if the trait cannot be found.
      • getAllTraits

        public final java.util.Map<ShapeId,​Trait> getAllTraits()
        Gets all of the traits attached to the shape.
        Returns:
        Returns the attached traits.
      • getMemberTrait

        @Deprecated
        public <T extends Trait> java.util.Optional<T> getMemberTrait​(ShapeIndex index,
                                                                      java.lang.Class<T> trait)
        Deprecated.
      • getMemberTrait

        public <T extends Trait> java.util.Optional<T> getMemberTrait​(Model model,
                                                                      java.lang.Class<T> trait)
        Gets a trait from the member shape or from the shape targeted by the member.

        If the shape is not a member, then the method functions the same as getTrait(Class).

        Type Parameters:
        T - Trait type to get.
        Parameters:
        model - Model used to find member targets.
        trait - Trait type to get.
        Returns:
        Returns the optionally found trait on the shape or member.
        See Also:
        getTrait(Class)
      • findMemberTrait

        @Deprecated
        public java.util.Optional<Trait> findMemberTrait​(ShapeIndex index,
                                                         java.lang.String traitName)
        Deprecated.
      • findMemberTrait

        public java.util.Optional<Trait> findMemberTrait​(Model model,
                                                         java.lang.String traitName)
        Gets a trait from the member shape or from the shape targeted by the member.

        If the shape is not a member, then the method functions the same as findTrait(String).

        Parameters:
        model - Model used to find member targets.
        traitName - Trait name to get.
        Returns:
        Returns the optionally found trait on the shape or member.
        See Also:
        findTrait(String)
      • asBlobShape

        public java.util.Optional<BlobShape> asBlobShape()
        Returns:
        Optionally returns the shape as a BlobShape.
      • asBooleanShape

        public java.util.Optional<BooleanShape> asBooleanShape()
        Returns:
        Optionally returns the shape as a BooleanShape.
      • asByteShape

        public java.util.Optional<ByteShape> asByteShape()
        Returns:
        Optionally returns the shape as a ByteShape.
      • asShortShape

        public java.util.Optional<ShortShape> asShortShape()
        Returns:
        Optionally returns the shape as a ShortShape.
      • asFloatShape

        public java.util.Optional<FloatShape> asFloatShape()
        Returns:
        Optionally returns the shape as a FloatShape.
      • asDocumentShape

        public java.util.Optional<DocumentShape> asDocumentShape()
        Returns:
        Optionally returns the shape as a DocumentShape.
      • asDoubleShape

        public java.util.Optional<DoubleShape> asDoubleShape()
        Returns:
        Optionally returns the shape as a DoubleShape.
      • asIntegerShape

        public java.util.Optional<IntegerShape> asIntegerShape()
        Returns:
        Optionally returns the shape as a IntegerShape.
      • asListShape

        public java.util.Optional<ListShape> asListShape()
        Returns:
        Optionally returns the shape as a ListShape.
      • asSetShape

        public java.util.Optional<SetShape> asSetShape()
        Returns:
        Optionally returns the shape as a SetShape.
      • asLongShape

        public java.util.Optional<LongShape> asLongShape()
        Returns:
        Optionally returns the shape as a LongShape.
      • asMapShape

        public java.util.Optional<MapShape> asMapShape()
        Returns:
        Optionally returns the shape as a MapShape.
      • asMemberShape

        public java.util.Optional<MemberShape> asMemberShape()
        Returns:
        Optionally returns the shape as a MemberShape.
      • asOperationShape

        public java.util.Optional<OperationShape> asOperationShape()
        Returns:
        Optionally returns the shape as an OperationShape.
      • asResourceShape

        public java.util.Optional<ResourceShape> asResourceShape()
        Returns:
        Optionally returns the shape as a ResourceShape.
      • asServiceShape

        public java.util.Optional<ServiceShape> asServiceShape()
        Returns:
        Optionally returns the shape as a ServiceShape.
      • asStringShape

        public java.util.Optional<StringShape> asStringShape()
        Returns:
        Optionally returns the shape as a StringShape.
      • asStructureShape

        public java.util.Optional<StructureShape> asStructureShape()
        Returns:
        Optionally returns the shape as a StructureShape.
      • asUnionShape

        public java.util.Optional<UnionShape> asUnionShape()
        Returns:
        Optionally returns the shape as a UnionShape.
      • asTimestampShape

        public java.util.Optional<TimestampShape> asTimestampShape()
        Returns:
        Optionally returns the shape as a TimestampShape.
      • isBigDecimalShape

        public final boolean isBigDecimalShape()
        Returns:
        Returns true if the shape is a BigDecimalShape shape.
      • isBigIntegerShape

        public final boolean isBigIntegerShape()
        Returns:
        Returns true if the shape is a BigIntegerShape shape.
      • isBlobShape

        public final boolean isBlobShape()
        Returns:
        Returns true if the shape is a BlobShape shape.
      • isBooleanShape

        public final boolean isBooleanShape()
        Returns:
        Returns true if the shape is a BooleanShape shape.
      • isByteShape

        public final boolean isByteShape()
        Returns:
        Returns true if the shape is a ByteShape shape.
      • isShortShape

        public final boolean isShortShape()
        Returns:
        Returns true if the shape is a ShortShape shape.
      • isFloatShape

        public final boolean isFloatShape()
        Returns:
        Returns true if the shape is a FloatShape shape.
      • isDocumentShape

        public final boolean isDocumentShape()
        Returns:
        Returns true if the shape is an DocumentShape shape.
      • isDoubleShape

        public final boolean isDoubleShape()
        Returns:
        Returns true if the shape is an DoubleShape shape.
      • isListShape

        public final boolean isListShape()
        Returns:
        Returns true if the shape is a ListShape shape.
      • isSetShape

        public final boolean isSetShape()
        Returns:
        Returns true if the shape is a SetShape shape.
      • isIntegerShape

        public final boolean isIntegerShape()
        Returns:
        Returns true if the shape is a IntegerShape shape.
      • isLongShape

        public final boolean isLongShape()
        Returns:
        Returns true if the shape is a LongShape shape.
      • isMapShape

        public final boolean isMapShape()
        Returns:
        Returns true if the shape is a MapShape shape.
      • isMemberShape

        public final boolean isMemberShape()
        Returns:
        Returns true if the shape is a MemberShape shape.
      • isOperationShape

        public final boolean isOperationShape()
        Returns:
        Returns true if the shape is an OperationShape shape.
      • isResourceShape

        public final boolean isResourceShape()
        Returns:
        Returns true if the shape is a ResourceShape shape.
      • isServiceShape

        public final boolean isServiceShape()
        Returns:
        Returns true if the shape is a ServiceShape shape.
      • isStringShape

        public final boolean isStringShape()
        Returns:
        Returns true if the shape is a StringShape shape.
      • isStructureShape

        public final boolean isStructureShape()
        Returns:
        Returns true if the shape is a StructureShape shape.
      • isUnionShape

        public final boolean isUnionShape()
        Returns:
        Returns true if the shape is a UnionShape shape.
      • isTimestampShape

        public final boolean isTimestampShape()
        Returns:
        Returns true if the shape is a TimestampShape shape.
      • members

        public java.util.Collection<MemberShape> members()
        Gets all of the members contained in the shape.
        Returns:
        Returns the members contained in the shape (if any).
      • toShapeId

        public ShapeId toShapeId()
        Specified by:
        toShapeId in interface ToShapeId
        Returns:
        Returns the shape ID of an object.
      • getTags

        public final java.util.List<java.lang.String> getTags()
        Specified by:
        getTags in interface software.amazon.smithy.utils.Tagged
      • compareTo

        public int compareTo​(Shape other)
        Specified by:
        compareTo in interface java.lang.Comparable<Shape>
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

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

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