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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a member to the builder.addMember(String memberName, String enumValue, Consumer<MemberShape.Builder> memberUpdater) Adds a member to the builder.addMember(MemberShape member) Adds a member to the shape.Adds a mixin to the shape.build()Creates an immutable object that is created from the properties that have been set on the builder.Removes all members from the builder.Removes mixins from a shape and flattens them into the shape.Gets the type of shape being built.Sets the shape ID of the shape.Sets the shape ID of the shape.members(Collection<MemberShape> members) Replaces the members of the builder.removeMember(String member) Removes a member by name.removeMixin(ToShapeId shape) Removes a mixin from the shape by shape or ID.setMembersFromEnumTrait(EnumTrait trait) Sets enum members from anEnumTrait.setMembersFromEnumTrait(EnumTrait trait, boolean synthesizeNames) Sets enum members from anEnumTrait.Methods inherited from class software.amazon.smithy.model.shapes.AbstractShapeBuilder
addTrait, addTraits, clearMixins, clearTraits, getAllTraits, getId, getSourceLocation, mixins, removeTrait, removeTrait, source, source, traits
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
build
Description copied from interface:SmithyBuilderCreates an immutable object that is created from the properties that have been set on the builder.- Specified by:
buildin interfaceSmithyBuilder<StringShape>- Overrides:
buildin classStringShape.Builder- Returns:
- an instance of T
-
getShapeType
Description copied from class:AbstractShapeBuilderGets the type of shape being built.- Overrides:
getShapeTypein classStringShape.Builder- Returns:
- Returns the shape type.
-
id
Description copied from class:AbstractShapeBuilderSets the shape ID of the shape.- Overrides:
idin classAbstractShapeBuilder<StringShape.Builder,StringShape> - Parameters:
shapeId- Shape ID to set.- Returns:
- Returns the builder.
-
id
Description copied from class:AbstractShapeBuilderSets the shape ID of the shape.- Overrides:
idin classAbstractShapeBuilder<StringShape.Builder,StringShape> - Parameters:
id- Absolute shape ID string to set.- Returns:
- Returns the builder.
-
setMembersFromEnumTrait
Sets enum members from anEnumTrait.This is primarily useful when converting from string shapes to enums.
- Parameters:
trait- TheEnumTraitwhose 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
Sets enum members from anEnumTrait.This is primarily useful when converting from string shapes to enums.
- Parameters:
trait- TheEnumTraitwhose values should be converted to members.- Returns:
- Returns the builder.
-
members
Replaces the members of the builder.- Parameters:
members- Members to add to the builder.- Returns:
- Returns the builder.
-
clearMembers
Description copied from class:AbstractShapeBuilderRemoves all members from the builder.- Overrides:
clearMembersin classAbstractShapeBuilder<StringShape.Builder,StringShape> - Returns:
- Returns the builder.
-
addMember
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:
addMemberin classAbstractShapeBuilder<StringShape.Builder,StringShape> - Parameters:
member- Member to add to the shape.- Returns:
- Returns the model assembler.
- Throws:
UnsupportedOperationException- if the shape does not support members.
-
addMember
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(String memberName, String enumValue, 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
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
Description copied from class:AbstractShapeBuilderAdds a mixin to the shape.- Overrides:
addMixinin classAbstractShapeBuilder<StringShape.Builder,StringShape> - Parameters:
shape- Mixin to add.- Returns:
- Returns the builder.
-
removeMixin
Description copied from class:AbstractShapeBuilderRemoves a mixin from the shape by shape or ID.- Overrides:
removeMixinin classAbstractShapeBuilder<StringShape.Builder,StringShape> - Parameters:
shape- Shape or shape ID to remove.- Returns:
- Returns the builder.
-
flattenMixins
Description copied from class:AbstractShapeBuilderRemoves 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:
flattenMixinsin classAbstractShapeBuilder<StringShape.Builder,StringShape> - Returns:
- Returns the updated builder.
-