Class EnumShape.Builder
- java.lang.Object
-
- software.amazon.smithy.model.shapes.AbstractShapeBuilder<StringShape.Builder,StringShape>
-
- software.amazon.smithy.model.shapes.StringShape.Builder
-
- software.amazon.smithy.model.shapes.EnumShape.Builder
-
- All Implemented Interfaces:
FromSourceLocation
,SmithyBuilder<StringShape>
- Enclosing class:
- EnumShape
public static final class EnumShape.Builder extends StringShape.Builder
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EnumShape.Builder
addMember(java.lang.String memberName, java.lang.String enumValue)
Adds a member to the builder.EnumShape.Builder
addMember(java.lang.String memberName, java.lang.String enumValue, java.util.function.Consumer<MemberShape.Builder> memberUpdater)
Adds a member to the builder.EnumShape.Builder
addMember(MemberShape member)
Adds a member to the shape.EnumShape.Builder
addMixin(Shape shape)
Adds a mixin to the shape.EnumShape
build()
Creates an immutable object that is created from the properties that have been set on the builder.EnumShape.Builder
clearMembers()
Removes all members from the builder.EnumShape.Builder
flattenMixins()
Removes mixins from a shape and flattens them into the shape.ShapeType
getShapeType()
Gets the type of shape being built.EnumShape.Builder
id(java.lang.String id)
Sets the shape ID of the shape.EnumShape.Builder
id(ShapeId shapeId)
Sets the shape ID of the shape.EnumShape.Builder
members(java.util.Collection<MemberShape> members)
Replaces the members of the builder.EnumShape.Builder
removeMember(java.lang.String member)
Removes a member by name.EnumShape.Builder
removeMixin(ToShapeId shape)
Removes a mixin from the shape by shape or ID.EnumShape.Builder
setMembersFromEnumTrait(EnumTrait trait)
Sets enum members from anEnumTrait
.EnumShape.Builder
setMembersFromEnumTrait(EnumTrait trait, boolean synthesizeNames)
Sets enum members from anEnumTrait
.EnumShape.Builder
source(SourceLocation source)
Sets the source location of the shape.-
Methods inherited from class software.amazon.smithy.model.shapes.AbstractShapeBuilder
addTrait, addTraits, clearMixins, clearTraits, getAllTraits, getId, getMember, getSourceLocation, mixins, removeTrait, removeTrait, source, traits
-
-
-
-
Method Detail
-
build
public EnumShape build()
Description copied from interface:SmithyBuilder
Creates an immutable object that is created from the properties that have been set on the builder.- Specified by:
build
in interfaceSmithyBuilder<StringShape>
- Overrides:
build
in classStringShape.Builder
- Returns:
- an instance of T
-
getShapeType
public ShapeType getShapeType()
Description copied from class:AbstractShapeBuilder
Gets the type of shape being built.- Overrides:
getShapeType
in classStringShape.Builder
- Returns:
- Returns the shape type.
-
id
public EnumShape.Builder id(ShapeId shapeId)
Description copied from class:AbstractShapeBuilder
Sets the shape ID of the shape.- Overrides:
id
in classAbstractShapeBuilder<StringShape.Builder,StringShape>
- Parameters:
shapeId
- Shape ID to set.- Returns:
- Returns the builder.
-
id
public EnumShape.Builder id(java.lang.String id)
Description copied from class:AbstractShapeBuilder
Sets the shape ID of the shape.- Overrides:
id
in classAbstractShapeBuilder<StringShape.Builder,StringShape>
- Parameters:
id
- Absolute shape ID string to set.- Returns:
- Returns the builder.
-
setMembersFromEnumTrait
public EnumShape.Builder setMembersFromEnumTrait(EnumTrait trait, boolean synthesizeNames)
Sets enum members from anEnumTrait
.This is primarily useful when converting from string shapes to enums.
- Parameters:
trait
- TheEnumTrait
whose values should be converted to members.synthesizeNames
- Whether to synthesize names if they aren't present in the enum trait.- Returns:
- Returns the builder.
-
setMembersFromEnumTrait
public EnumShape.Builder setMembersFromEnumTrait(EnumTrait trait)
Sets enum members from anEnumTrait
.This is primarily useful when converting from string shapes to enums.
- Parameters:
trait
- TheEnumTrait
whose values should be converted to members.- Returns:
- Returns the builder.
-
members
public EnumShape.Builder members(java.util.Collection<MemberShape> members)
Replaces the members of the builder.- Parameters:
members
- Members to add to the builder.- Returns:
- Returns the builder.
-
clearMembers
public EnumShape.Builder clearMembers()
Description copied from class:AbstractShapeBuilder
Removes all members from the builder.- Overrides:
clearMembers
in classAbstractShapeBuilder<StringShape.Builder,StringShape>
- Returns:
- Returns the builder.
-
addMember
public EnumShape.Builder addMember(MemberShape member)
Adds a member to the shape.If the member does not already have an
EnumValueTrait
, one will be generated with the value being equal to the member name.- Overrides:
addMember
in classAbstractShapeBuilder<StringShape.Builder,StringShape>
- Parameters:
member
- Member to add to the shape.- Returns:
- Returns the model assembler.
- Throws:
java.lang.UnsupportedOperationException
- if the shape does not support members.
-
addMember
public EnumShape.Builder addMember(java.lang.String memberName, java.lang.String enumValue)
Adds a member to the builder.- Parameters:
memberName
- Member name to add.enumValue
- The value of the enum.- Returns:
- Returns the builder.
-
addMember
public EnumShape.Builder addMember(java.lang.String memberName, java.lang.String enumValue, java.util.function.Consumer<MemberShape.Builder> memberUpdater)
Adds a member to the builder.- Parameters:
memberName
- Member name to add.enumValue
- The value of the enum.memberUpdater
- Consumer that can update the created member shape.- Returns:
- Returns the builder.
-
removeMember
public EnumShape.Builder removeMember(java.lang.String member)
Removes a member by name.Note that removing a member that was added by a mixin results in an inconsistent model. It's best to use ModelTransform to ensure that the model remains consistent when removing members.
- Parameters:
member
- Member name to remove.- Returns:
- Returns the builder.
-
addMixin
public EnumShape.Builder addMixin(Shape shape)
Description copied from class:AbstractShapeBuilder
Adds a mixin to the shape.- Overrides:
addMixin
in classAbstractShapeBuilder<StringShape.Builder,StringShape>
- Parameters:
shape
- Mixin to add.- Returns:
- Returns the builder.
-
removeMixin
public EnumShape.Builder removeMixin(ToShapeId shape)
Description copied from class:AbstractShapeBuilder
Removes a mixin from the shape by shape or ID.- Overrides:
removeMixin
in classAbstractShapeBuilder<StringShape.Builder,StringShape>
- Parameters:
shape
- Shape or shape ID to remove.- Returns:
- Returns the builder.
-
flattenMixins
public EnumShape.Builder flattenMixins()
Description copied from class:AbstractShapeBuilder
Removes mixins from a shape and flattens them into the shape.Flattening a mixin into a shape copies the traits and members of a mixin onto the shape, effectively resulting in the same shape but with no trace of the mixin relationship.
- Overrides:
flattenMixins
in classAbstractShapeBuilder<StringShape.Builder,StringShape>
- Returns:
- Returns the updated builder.
-
source
public EnumShape.Builder source(SourceLocation source)
Description copied from class:AbstractShapeBuilder
Sets the source location of the shape.- Overrides:
source
in classAbstractShapeBuilder<StringShape.Builder,StringShape>
- Parameters:
source
- Source location to set.- Returns:
- Returns the builder.
-
-