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:
Comparable<Shape>
,FromSourceLocation
,ToShapeId
,Tagged
,ToSmithyBuilder<StringShape>
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescription<R> R
accept
(ShapeVisitor<R> cases) Dispatches the shape to the appropriateShapeVisitor
method.static EnumShape.Builder
builder()
static boolean
canConvertToEnum
(StringShape shape, boolean synthesizeEnumNames) Determines whether a given string shape can be converted to an enum shape.Attempts to find a trait applied to the shape by name.fromStringShape
(StringShape shape) Converts a baseStringShape
to anEnumShape
if possible.fromStringShape
(StringShape shape, boolean synthesizeNames) Converts a baseStringShape
to anEnumShape
if possible.Gets the members of the shape, including mixin members.Gets a map of enum member names to their corresponding values.getType()
Gets the type of the shape.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 Details
-
getEnumValues
Gets a map of enum member names to their corresponding values.- Returns:
- A map of member names to enum values.
-
getAllMembers
Gets the members of the shape, including mixin members.- Overrides:
getAllMembers
in classShape
- Returns:
- Returns the immutable member map.
-
findTrait
Description copied from class:Shape
Attempts to find a trait applied to the shape by name. -
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 interfaceToSmithyBuilder<StringShape>
- Overrides:
toBuilder
in classStringShape
- Returns:
- a builder for type T
-
accept
Description copied from class:Shape
Dispatches the shape to the appropriateShapeVisitor
method.- Overrides:
accept
in classStringShape
- Type Parameters:
R
- Return type of the accept.- Parameters:
cases
- ShapeVisitor to use.- Returns:
- Returns the result.
-
asEnumShape
- Overrides:
asEnumShape
in classShape
- Returns:
- Optionally returns the shape as a
EnumShape
.
-
fromStringShape
Converts a baseStringShape
to anEnumShape
if 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 baseStringShape
to convert.synthesizeNames
- Whether names should be synthesized if possible.- Returns:
- Optionally returns an
EnumShape
equivalent of the given shape.
-
fromStringShape
Converts a baseStringShape
to anEnumShape
if possible. The result will be empty if the given shape doesn't have theEnumTrait
or if the enum definitions don't have names.- Parameters:
shape
- A baseStringShape
to convert.- Returns:
- Optionally returns an
EnumShape
equivalent of the given shape.
-
canConvertToEnum
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
Description copied from class:Shape
Gets the type of the shape.- Overrides:
getType
in classStringShape
- Returns:
- Returns the type;
-