Class EnumShape
- java.lang.Object
-
- software.amazon.smithy.model.shapes.Shape
-
- software.amazon.smithy.model.shapes.SimpleShape
-
- software.amazon.smithy.model.shapes.StringShape
-
- software.amazon.smithy.model.shapes.EnumShape
-
- All Implemented Interfaces:
java.lang.Comparable<Shape>,FromSourceLocation,ToShapeId,Tagged,ToSmithyBuilder<StringShape>
public final class EnumShape extends StringShape
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEnumShape.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> Raccept(ShapeVisitor<R> cases)Dispatches the shape to the appropriateShapeVisitormethod.java.util.Optional<EnumShape>asEnumShape()static EnumShape.Builderbuilder()static booleancanConvertToEnum(StringShape shape, boolean synthesizeEnumNames)Determines whether a given string shape can be converted to an enum shape.java.util.Optional<Trait>findTrait(ShapeId id)Attempts to find a trait applied to the shape by name.static java.util.Optional<EnumShape>fromStringShape(StringShape shape)Converts a baseStringShapeto anEnumShapeif possible.static java.util.Optional<EnumShape>fromStringShape(StringShape shape, boolean synthesizeNames)Converts a baseStringShapeto anEnumShapeif possible.java.util.Map<java.lang.String,MemberShape>getAllMembers()Gets the members of the shape, including mixin members.java.util.Map<java.lang.String,java.lang.String>getEnumValues()Gets a map of enum member names to their corresponding values.ShapeTypegetType()Gets the type of the shape.EnumShape.BuildertoBuilder()Take this object and create a builder that contains all of the current property values of this object.-
Methods inherited from class software.amazon.smithy.model.shapes.StringShape
asStringShape
-
Methods inherited from class software.amazon.smithy.model.shapes.Shape
asBigDecimalShape, asBigIntegerShape, asBlobShape, asBooleanShape, asByteShape, asDocumentShape, asDoubleShape, asFloatShape, asIntegerShape, asIntEnumShape, asListShape, asLongShape, asMapShape, asMemberShape, asOperationShape, asResourceShape, asServiceShape, asSetShape, asShortShape, asStructureShape, asTimestampShape, asUnionShape, compareTo, equals, expectTrait, findMemberTrait, findTrait, getAllTraits, getId, getIntroducedTraits, getMember, getMemberNames, getMemberTrait, getMixins, getRequiredMembers, getSourceLocation, getTags, getTrait, hashCode, hasTrait, hasTrait, hasTrait, isBigDecimalShape, isBigIntegerShape, isBlobShape, isBooleanShape, isByteShape, isDocumentShape, isDoubleShape, isEnumShape, isFloatShape, isIntegerShape, isIntEnumShape, isListShape, isLongShape, isMapShape, isMemberShape, isOperationShape, isResourceShape, isServiceShape, isSetShape, isShortShape, isStringShape, isStructureShape, isTimestampShape, isUnionShape, members, shapeToBuilder, toShapeId, toString, validateMemberShapeIds, validateMixins
-
-
-
-
Method Detail
-
getEnumValues
public java.util.Map<java.lang.String,java.lang.String> getEnumValues()
Gets a map of enum member names to their corresponding values.- Returns:
- A map of member names to enum values.
-
getAllMembers
public java.util.Map<java.lang.String,MemberShape> getAllMembers()
Gets the members of the shape, including mixin members.- Overrides:
getAllMembersin classShape- Returns:
- Returns the immutable member map.
-
findTrait
public java.util.Optional<Trait> findTrait(ShapeId id)
Description copied from class:ShapeAttempts to find a trait applied to the shape by name.
-
builder
public static EnumShape.Builder builder()
-
toBuilder
public EnumShape.Builder toBuilder()
Description copied from interface:ToSmithyBuilderTake this object and create a builder that contains all of the current property values of this object.- Specified by:
toBuilderin interfaceToSmithyBuilder<StringShape>- Overrides:
toBuilderin classStringShape- Returns:
- a builder for type T
-
accept
public <R> R accept(ShapeVisitor<R> cases)
Description copied from class:ShapeDispatches the shape to the appropriateShapeVisitormethod.- Overrides:
acceptin classStringShape- Type Parameters:
R- Return type of the accept.- Parameters:
cases- ShapeVisitor to use.- Returns:
- Returns the result.
-
asEnumShape
public java.util.Optional<EnumShape> asEnumShape()
- Overrides:
asEnumShapein classShape- Returns:
- Optionally returns the shape as a
EnumShape.
-
fromStringShape
public static java.util.Optional<EnumShape> fromStringShape(StringShape shape, boolean synthesizeNames)
Converts a baseStringShapeto anEnumShapeif possible. The result will be empty if the given shape doesn't have theEnumTrait, if the enum doesn't have names and name synthesization is disabled, or if a name cannot be synthesized.- Parameters:
shape- A baseStringShapeto convert.synthesizeNames- Whether names should be synthesized if possible.- Returns:
- Optionally returns an
EnumShapeequivalent of the given shape.
-
fromStringShape
public static java.util.Optional<EnumShape> fromStringShape(StringShape shape)
Converts a baseStringShapeto anEnumShapeif possible. The result will be empty if the given shape doesn't have theEnumTraitor if the enum definitions don't have names.- Parameters:
shape- A baseStringShapeto convert.- Returns:
- Optionally returns an
EnumShapeequivalent 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:ShapeGets the type of the shape.- Overrides:
getTypein classStringShape- Returns:
- Returns the type;
-
-