Class EnumShape

All Implemented Interfaces:
Comparable<Shape>, FromSourceLocation, ToShapeId, Tagged, ToSmithyBuilder<StringShape>

public final class EnumShape extends StringShape
  • Method Details

    • getEnumValues

      public Map<String,String> getEnumValues()
      Gets a map of enum member names to their corresponding values.
      Returns:
      A map of member names to enum values.
    • getAllMembers

      public Map<String,MemberShape> getAllMembers()
      Gets the members of the shape, including mixin members.
      Overrides:
      getAllMembers in class Shape
      Returns:
      Returns the immutable member map.
    • findTrait

      public Optional<Trait> findTrait(ShapeId id)
      Description copied from class: Shape
      Attempts to find a trait applied to the shape by name.
      Overrides:
      findTrait in class Shape
      Parameters:
      id - The trait shape ID.
      Returns:
      Returns the optionally found trait.
    • builder

      public static EnumShape.Builder builder()
    • toBuilder

      public EnumShape.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<StringShape>
      Overrides:
      toBuilder in class StringShape
      Returns:
      a builder for type T
    • accept

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

      public Optional<EnumShape> asEnumShape()
      Overrides:
      asEnumShape in class Shape
      Returns:
      Optionally returns the shape as a EnumShape.
    • fromStringShape

      public static Optional<EnumShape> fromStringShape(StringShape shape, boolean synthesizeNames)
      Converts a base StringShape to an EnumShape if possible. The result will be empty if the given shape doesn't have the EnumTrait, if the enum doesn't have names and name synthesization is disabled, or if a name cannot be synthesized.
      Parameters:
      shape - A base StringShape to convert.
      synthesizeNames - Whether names should be synthesized if possible.
      Returns:
      Optionally returns an EnumShape equivalent of the given shape.
    • fromStringShape

      public static Optional<EnumShape> fromStringShape(StringShape shape)
      Converts a base StringShape to an EnumShape if possible. The result will be empty if the given shape doesn't have the EnumTrait or if the enum definitions don't have names.
      Parameters:
      shape - A base StringShape to convert.
      Returns:
      Optionally returns an EnumShape equivalent of the given shape.
    • canConvertToEnum

      public static boolean canConvertToEnum(StringShape shape, boolean synthesizeEnumNames)
      Determines whether a given string shape can be converted to an enum shape.
      Parameters:
      shape - The string shape to be converted.
      synthesizeEnumNames - Whether synthesizing enum names should be accounted for.
      Returns:
      Returns true if the string shape can be converted to an enum shape.
    • getType

      public ShapeType getType()
      Description copied from class: Shape
      Gets the type of the shape.
      Overrides:
      getType in class StringShape
      Returns:
      Returns the type;