Class MemberShape

  • All Implemented Interfaces:
    java.lang.Comparable<Shape>, FromSourceLocation, ToShapeId, software.amazon.smithy.utils.Tagged, software.amazon.smithy.utils.ToSmithyBuilder<MemberShape>

    public final class MemberShape
    extends Shape
    implements software.amazon.smithy.utils.ToSmithyBuilder<MemberShape>
    Represents a member that targets another shape by ID.
    • Method Detail

      • getContainer

        public ShapeId getContainer()
        Gets the shape in which the member is contained.
        Returns:
        Returns the containing shape id.
      • accept

        public <R> R accept​(ShapeVisitor<R> cases)
        Description copied from class: Shape
        Dispatches the shape to the appropriate ShapeVisitor method.
        Specified by:
        accept in class Shape
        Type Parameters:
        R - Return type of the accept.
        Parameters:
        cases - NeighborVisitor to use.
        Returns:
        Returns the result.
      • getTarget

        public ShapeId getTarget()
        Get the targeted member shape ID.
        Returns:
        Returns the member shape ID.
      • getMemberName

        public java.lang.String getMemberName()
        Get the member name of the member.
        Returns:
        Returns the member name.
      • isRequired

        public boolean isRequired()
        Returns:
        Returns true if the member has the required trait.
      • isOptional

        public boolean isOptional()
        Returns:
        Returns true if the member is not required.
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class Shape
      • getMemberTrait

        @Deprecated
        public <T extends Trait> java.util.Optional<T> getMemberTrait​(ShapeIndex index,
                                                                      java.lang.Class<T> trait)
        Deprecated.
        Overrides:
        getMemberTrait in class Shape
      • findMemberTrait

        @Deprecated
        public java.util.Optional<Trait> findMemberTrait​(ShapeIndex index,
                                                         java.lang.String traitName)
        Deprecated.
        Overrides:
        findMemberTrait in class Shape
      • getMemberTrait

        public <T extends Trait> java.util.Optional<T> getMemberTrait​(Model model,
                                                                      java.lang.Class<T> trait)
        Description copied from class: Shape
        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 Shape.getTrait(Class).

        Overrides:
        getMemberTrait in class Shape
        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:
        Shape.getTrait(Class)
      • findMemberTrait

        public java.util.Optional<Trait> findMemberTrait​(Model model,
                                                         java.lang.String traitName)
        Description copied from class: Shape
        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 Shape.findTrait(String).

        Overrides:
        findMemberTrait in class Shape
        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:
        Shape.findTrait(String)