Class EnumTrait
- java.lang.Object
-
- software.amazon.smithy.model.traits.AbstractTrait
-
- software.amazon.smithy.model.traits.EnumTrait
-
- All Implemented Interfaces:
FromSourceLocation
,ToNode
,ToShapeId
,Trait
,software.amazon.smithy.utils.ToSmithyBuilder<EnumTrait>
public final class EnumTrait extends AbstractTrait implements software.amazon.smithy.utils.ToSmithyBuilder<EnumTrait>
Constrains string values to one of the predefined enum constants.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EnumTrait.Builder
Builder used to create the enum trait.static class
EnumTrait.Provider
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EnumTrait.Builder
builder()
protected Node
createNode()
The result of toNode is used for hashCodes and equality.java.util.Map<java.lang.String,EnumConstantBody>
getValues()
Gets the enum value to body.boolean
hasNames()
Checks if all of the constants of an enum define a name.EnumTrait.Builder
toBuilder()
-
Methods inherited from class software.amazon.smithy.model.traits.AbstractTrait
equals, getSourceLocation, hashCode, toNode, toShapeId, toString
-
-
-
-
Field Detail
-
ID
public static final ShapeId ID
-
-
Method Detail
-
getValues
public java.util.Map<java.lang.String,EnumConstantBody> getValues()
Gets the enum value to body.- Returns:
- returns the enum constant mapping.
-
hasNames
public boolean hasNames()
Checks if all of the constants of an enum define a name.Note that either all constants must have a name or no constants can have a name.
- Returns:
- Returns true if all constants define a name.
-
createNode
protected Node createNode()
Description copied from class:AbstractTrait
The result of toNode is used for hashCodes and equality. Subclasses must implement createNode to turn the trait into a Node. This is then cached for subsequent retrievals.- Specified by:
createNode
in classAbstractTrait
- Returns:
- Returns the trait as a node.
-
toBuilder
public EnumTrait.Builder toBuilder()
- Specified by:
toBuilder
in interfacesoftware.amazon.smithy.utils.ToSmithyBuilder<EnumTrait>
-
builder
public static EnumTrait.Builder builder()
- Returns:
- Returns an enum trait builder.
-
-