Class MemberShape

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

public final class MemberShape extends Shape implements ToSmithyBuilder<MemberShape>
Represents a member that targets another shape by ID.
  • Method Details

    • builder

      public static MemberShape.Builder builder()
    • toBuilder

      public MemberShape.Builder toBuilder()
      Description copied from interface: ToSmithyBuilder
      Take this object and create a builder that contains all of the current property values of this object.
      Specified by:
      toBuilder in interface ToSmithyBuilder<MemberShape>
      Returns:
      a builder for type T
    • 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> visitor)
      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:
      visitor - ShapeVisitor to use.
      Returns:
      Returns the result.
    • asMemberShape

      public Optional<MemberShape> asMemberShape()
      Overrides:
      asMemberShape in class Shape
      Returns:
      Optionally returns the shape as a MemberShape.
    • getType

      public ShapeType getType()
      Description copied from class: Shape
      Gets the type of the shape.
      Specified by:
      getType in class Shape
      Returns:
      Returns the type;
    • getTarget

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

      public 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.
    • hasNullDefault

      public boolean hasNullDefault()
      Returns:
      Returns true if the member has a default set explicitly to null.
    • hasNonNullDefault

      public boolean hasNonNullDefault()
      Returns:
      Returns true if the member has a default not set to null.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Shape
    • getMemberTrait

      public <T extends Trait> Optional<T> getMemberTrait(Model model, 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:
    • findMemberTrait

      public Optional<Trait> findMemberTrait(Model model, 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: