Package software.amazon.smithy.model
Class Model.Builder
- java.lang.Object
-
- software.amazon.smithy.model.Model.Builder
-
- All Implemented Interfaces:
SmithyBuilder<Model>
- Enclosing class:
- Model
public static final class Model.Builder extends java.lang.Object implements SmithyBuilder<Model>
Builder used to create a Model.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Model.Builder
addShape(Shape shape)
Add a shape to the builder.<S extends Shape>
Model.BuilderaddShapes(java.util.Collection<S> shapes)
Adds a collection of shapes to the builder.Model.Builder
addShapes(Model model)
Adds the shapes of another model to the builder.Model.Builder
addShapes(Shape... shapes)
Adds a variadic list of shapes.Model
build()
Creates an immutable object that is created from the properties that have been set on the builder.Model.Builder
clearMetadata()
java.util.Map<ShapeId,Shape>
getCurrentShapes()
Gets an immutable view of the current shapes in the builder.Model.Builder
metadata(java.util.Map<java.lang.String,Node> metadata)
Model.Builder
putMetadataProperty(java.lang.String key, Node value)
Model.Builder
removeMetadataProperty(java.lang.String key)
Model.Builder
removeShape(ShapeId shapeId)
Removes a shape from the builder by ID.
-
-
-
Method Detail
-
metadata
public Model.Builder metadata(java.util.Map<java.lang.String,Node> metadata)
-
putMetadataProperty
public Model.Builder putMetadataProperty(java.lang.String key, Node value)
-
removeMetadataProperty
public Model.Builder removeMetadataProperty(java.lang.String key)
-
clearMetadata
public Model.Builder clearMetadata()
-
addShape
public Model.Builder addShape(Shape shape)
Add a shape to the builder.MemberShape
shapes are not added to the model directly. They must be added by adding their containing shapes (e.g., to add a list member, you must add the list shape that contains it). Any member shape provided to any of the methods used to add shapes to the model are ignored.- Parameters:
shape
- Shape to add.- Returns:
- Returns the builder.
-
addShapes
public Model.Builder addShapes(Model model)
Adds the shapes of another model to the builder.- Parameters:
model
- Model to add shapes from.- Returns:
- Returns the builder.
-
addShapes
public <S extends Shape> Model.Builder addShapes(java.util.Collection<S> shapes)
Adds a collection of shapes to the builder.- Type Parameters:
S
- Type of shape being added.- Parameters:
shapes
- Collection of Shapes to add.- Returns:
- Returns the builder.
-
addShapes
public Model.Builder addShapes(Shape... shapes)
Adds a variadic list of shapes.- Parameters:
shapes
- Shapes to add.- Returns:
- Returns the builder.
-
removeShape
public Model.Builder removeShape(ShapeId shapeId)
Removes a shape from the builder by ID.Members of shapes are automatically removed when their containing shape is removed.
- Parameters:
shapeId
- Shape to remove.- Returns:
- Returns the builder.
-
getCurrentShapes
public java.util.Map<ShapeId,Shape> getCurrentShapes()
Gets an immutable view of the current shapes in the builder.The returned view may not be updated as shapes are added to the builder.
- Returns:
- Returns the current shapes in the builder.
-
build
public Model 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<Model>
- Returns:
- an instance of T
-
-