Class ModelSerializer.Builder
- java.lang.Object
-
- software.amazon.smithy.model.shapes.ModelSerializer.Builder
-
- All Implemented Interfaces:
SmithyBuilder<ModelSerializer>
- Enclosing class:
- ModelSerializer
public static final class ModelSerializer.Builder extends java.lang.Object implements SmithyBuilder<ModelSerializer>
Builder used to createModelSerializer
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ModelSerializer
build()
Creates an immutable object that is created from the properties that have been set on the builder.ModelSerializer.Builder
includePrelude(boolean includePrelude)
Enables or disables including the prelude in the serialized model.ModelSerializer.Builder
metadataFilter(java.util.function.Predicate<java.lang.String> metadataFilter)
Predicate that determines if a metadata is serialized.ModelSerializer.Builder
shapeFilter(java.util.function.Predicate<Shape> shapeFilter)
Predicate that determines if a shape and its traits are serialized.ModelSerializer.Builder
traitFilter(java.util.function.Predicate<Trait> traitFilter)
Sets a predicate that can be used to filter trait values from appearing in the serialized model.ModelSerializer.Builder
version(java.lang.String version)
Sets the IDL version to serialize.
-
-
-
Method Detail
-
metadataFilter
public ModelSerializer.Builder metadataFilter(java.util.function.Predicate<java.lang.String> metadataFilter)
Predicate that determines if a metadata is serialized.- Parameters:
metadataFilter
- Predicate that accepts a metadata key.- Returns:
- Returns the builder.
-
shapeFilter
public ModelSerializer.Builder shapeFilter(java.util.function.Predicate<Shape> shapeFilter)
Predicate that determines if a shape and its traits are serialized.- Parameters:
shapeFilter
- Predicate that accepts a shape.- Returns:
- Returns the builder.
-
includePrelude
public ModelSerializer.Builder includePrelude(boolean includePrelude)
Enables or disables including the prelude in the serialized model.By default, the prelude is not included.
This should nearly always be left at default, as per the spec the prelude is inherently part of every model, and so any Smithy implementation must build in an understanding of the prelude. Disabling this filter can be useful for those implementations to allow them to build their understanding of it from a JSON version of the prelude.
- Parameters:
includePrelude
- boolean indicating whether the prelude should be included or not.- Returns:
- Returns the builder.
-
traitFilter
public ModelSerializer.Builder traitFilter(java.util.function.Predicate<Trait> traitFilter)
Sets a predicate that can be used to filter trait values from appearing in the serialized model.Note that this does not filter out trait definitions. It only filters out instances of traits from being serialized on shapes.
- Parameters:
traitFilter
- Predicate that filters out trait definitions.- Returns:
- Returns the builder.
-
version
public ModelSerializer.Builder version(java.lang.String version)
Sets the IDL version to serialize. Defaults to 2.0.Version "1.0" serialization cannot be used with
includePrelude
.- Parameters:
version
- IDL version to set. Can be "1", "1.0", "2", or "2.0". "1" and "2" are normalized to "1.0" and "2.0".- Returns:
- Returns the builder.
-
build
public ModelSerializer 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<ModelSerializer>
- Returns:
- an instance of T
-
-