Class Model
- java.lang.Object
-
- software.amazon.smithy.model.Model
-
- All Implemented Interfaces:
ToSmithyBuilder<Model>
public final class Model extends java.lang.Object implements ToSmithyBuilder<Model>
A Smithy model that contains shapes, traits, metadata, and various computed information used to interpret the model.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Model.Builder
Builder used to create a Model.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
MODEL_VERSION
Specifies the highest supported version of the IDL.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ModelAssembler
assembler()
Assembles and validates a Smithy model from files, nodes, and other disparate sources.static ModelAssembler
assembler(java.lang.ClassLoader classLoader)
Creates aModelAssembler
that is configured to discover traits, validators, and built-in validators using the givenClassLoader
.static Model.Builder
builder()
Builds an explicitly configured Smithy model.boolean
equals(java.lang.Object other)
Shape
expectShape(ShapeId id)
<T extends Shape>
TexpectShape(ShapeId id, java.lang.Class<T> type)
java.util.Set<ShapeId>
getAppliedTraits()
Gets a set of every trait shape ID that is used in the model.java.util.Set<BigDecimalShape>
getBigDecimalShapes()
Gets an immutable set of all bigDecimals in the Model.java.util.Set<BigDecimalShape>
getBigDecimalShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all bigDecimals in the Model that have a specific trait.java.util.Set<BigIntegerShape>
getBigIntegerShapes()
Gets an immutable set of all bigIntegers in the Model.java.util.Set<BigIntegerShape>
getBigIntegerShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all bigIntegers in the Model that have a specific trait.java.util.Set<BlobShape>
getBlobShapes()
Gets an immutable set of all blobs in the Model.java.util.Set<BlobShape>
getBlobShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all blobs in the Model that have a specific trait.java.util.Set<BooleanShape>
getBooleanShapes()
Gets an immutable set of all booleans in the Model.java.util.Set<BooleanShape>
getBooleanShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all booleans in the Model that have a specific trait.java.util.Set<ByteShape>
getByteShapes()
Gets an immutable set of all bytes in the Model.java.util.Set<ByteShape>
getByteShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all bytes in the Model that have a specific trait.java.util.Set<DocumentShape>
getDocumentShapes()
Gets an immutable set of all documents in the Model.java.util.Set<DocumentShape>
getDocumentShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all documents in the Model that have a specific trait.java.util.Set<DoubleShape>
getDoubleShapes()
Gets an immutable set of all doubles in the Model.java.util.Set<DoubleShape>
getDoubleShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all doubles in the Model that have a specific trait.java.util.Set<EnumShape>
getEnumShapes()
Gets an immutable set of all enums in the Model.java.util.Set<EnumShape>
getEnumShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all enums in the Model that have a specific trait.java.util.Set<FloatShape>
getFloatShapes()
Gets an immutable set of all floats in the Model.java.util.Set<FloatShape>
getFloatShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all floats in the Model that have a specific trait.java.util.Set<IntegerShape>
getIntegerShapes()
Gets an immutable set of all integers in the Model.java.util.Set<IntegerShape>
getIntegerShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all integers in the Model that have a specific trait.java.util.Set<IntEnumShape>
getIntEnumShapes()
Gets an immutable set of all intEnums in the Model.java.util.Set<IntEnumShape>
getIntEnumShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all intEnums in the Model that have a specific trait.<T extends KnowledgeIndex>
TgetKnowledge(java.lang.Class<T> type)
Deprecated.<T extends KnowledgeIndex>
TgetKnowledge(java.lang.Class<T> type, java.util.function.Function<Model,T> constructor)
Gets a computed "knowledge index" of a specific type for the model and caches it for subsequent retrieval.java.util.Set<ListShape>
getListShapes()
Gets an immutable set of all lists in the Model.java.util.Set<ListShape>
getListShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all lists in the Model that have a specific trait.java.util.Set<LongShape>
getLongShapes()
Gets an immutable set of all longs in the Model.java.util.Set<LongShape>
getLongShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all longs in the Model that have a specific trait.java.util.Set<MapShape>
getMapShapes()
Gets an immutable set of all maps in the Model.java.util.Set<MapShape>
getMapShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all maps in the Model that have a specific trait.java.util.Set<MemberShape>
getMemberShapes()
Gets an immutable set of all members in the Model.java.util.Set<MemberShape>
getMemberShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all members in the Model that have a specific trait.java.util.Map<java.lang.String,Node>
getMetadata()
java.util.Optional<Node>
getMetadataProperty(java.lang.String name)
Gets a metadata property by namespace and name.java.util.Set<OperationShape>
getOperationShapes()
Gets an immutable set of all operations in the Model.java.util.Set<OperationShape>
getOperationShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all operations in the Model that have a specific trait.java.util.Set<ResourceShape>
getResourceShapes()
Gets an immutable set of all resources in the Model.java.util.Set<ResourceShape>
getResourceShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all resources in the Model that have a specific trait.java.util.Set<ServiceShape>
getServiceShapes()
Gets an immutable set of all services in the Model.java.util.Set<ServiceShape>
getServiceShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all services in the Model that have a specific trait.java.util.Set<SetShape>
getSetShapes()
Deprecated.java.util.Set<SetShape>
getSetShapesWithTrait(java.lang.Class<? extends Trait> trait)
Deprecated.java.util.Optional<Shape>
getShape(ShapeId id)
java.util.Set<ShapeId>
getShapeIds()
Gets the immutable set ofShapeId
in the model.java.util.Set<Shape>
getShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets a set of shapes in the model marked with a specific trait.java.util.Set<Shape>
getShapesWithTrait(ToShapeId trait)
Gets a set of shapes in the model marked with a specific trait.java.util.Set<ShortShape>
getShortShapes()
Gets an immutable set of all shorts in the Model.java.util.Set<ShortShape>
getShortShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all shorts in the Model that have a specific trait.java.util.Set<StringShape>
getStringShapes()
Gets an immutable set of all strings in the Model.java.util.Set<StringShape>
getStringShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all strings in the Model that have a specific trait.java.util.Set<StructureShape>
getStructureShapes()
Gets an immutable set of all structures in the Model.java.util.Set<StructureShape>
getStructureShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all structures in the Model that have a specific trait.java.util.Set<TimestampShape>
getTimestampShapes()
Gets an immutable set of all timestamps in the Model.java.util.Set<TimestampShape>
getTimestampShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all timestamps in the Model that have a specific trait.java.util.Optional<TraitDefinition>
getTraitDefinition(ToShapeId traitId)
Gets the trait definition of a specific trait shape ID.java.util.Set<UnionShape>
getUnionShapes()
Gets an immutable set of all unions in the Model.java.util.Set<UnionShape>
getUnionShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all unions in the Model that have a specific trait.int
hashCode()
boolean
isTraitApplied(java.lang.Class<? extends Trait> trait)
Returns true if the given trait shape ID was used in the model.java.util.stream.Stream<Shape>
shapes()
Gets a stream ofShape
s in the index.<T extends Shape>
java.util.stream.Stream<T>shapes(java.lang.Class<T> shapeType)
Gets a stream of shapes in the index of a specific typeT
.Model.Builder
toBuilder()
Take this object and create a builder that contains all of the current property values of this object.java.util.Set<Shape>
toSet()
Converts the model to an immutable Set of shapes.<T extends Shape>
java.util.Set<T>toSet(java.lang.Class<T> shapeType)
Gets an immutable Set of shapes of a specific type.
-
-
-
Field Detail
-
MODEL_VERSION
public static final java.lang.String MODEL_VERSION
Specifies the highest supported version of the IDL.- See Also:
- Constant Field Values
-
-
Method Detail
-
builder
public static Model.Builder builder()
Builds an explicitly configured Smithy model.Note that the builder does not validate the correctness of the model. Use the
assembler()
method to build and validate a model.- Returns:
- Returns a model builder.
- See Also:
assembler()
-
assembler
public static ModelAssembler assembler()
Assembles and validates a Smithy model from files, nodes, and other disparate sources.- Returns:
- Returns a model assembler.
-
assembler
public static ModelAssembler assembler(java.lang.ClassLoader classLoader)
Creates aModelAssembler
that is configured to discover traits, validators, and built-in validators using the givenClassLoader
.- Parameters:
classLoader
- Class loader used to discover services.- Returns:
- Returns a model assembler.
-
getMetadataProperty
public java.util.Optional<Node> getMetadataProperty(java.lang.String name)
Gets a metadata property by namespace and name.- Parameters:
name
- Name of the property to retrieve.- Returns:
- Returns the optional property.
-
getMetadata
public java.util.Map<java.lang.String,Node> getMetadata()
- Returns:
- Gets the unmodifiable metadata of the model across all namespaces.
-
getTraitDefinition
public java.util.Optional<TraitDefinition> getTraitDefinition(ToShapeId traitId)
Gets the trait definition of a specific trait shape ID.- Parameters:
traitId
- ID of the shape to get the trait definition of.- Returns:
- Returns the optionally found trait definition.
-
getShapesWithTrait
public java.util.Set<Shape> getShapesWithTrait(ToShapeId trait)
Gets a set of shapes in the model marked with a specific trait.- Parameters:
trait
- Trait shape ID to look for on shapes.- Returns:
- Returns the immutable set of matching shapes.
-
getShapeIds
public java.util.Set<ShapeId> getShapeIds()
Gets the immutable set ofShapeId
in the model.- Returns:
- Returns the shape IDs.
-
getShapesWithTrait
public java.util.Set<Shape> getShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets a set of shapes in the model marked with a specific trait.The result is an exact match on trait classes and does not utilize any kind of polymorphic instance of checks.
- Parameters:
trait
- Trait class to look for on shapes.- Returns:
- Returns the immutable set of matching shapes.
-
getBigDecimalShapes
public java.util.Set<BigDecimalShape> getBigDecimalShapes()
Gets an immutable set of all bigDecimals in the Model.- Returns:
- Returns the Set of
bigDecimals
s.
-
getBigDecimalShapesWithTrait
public java.util.Set<BigDecimalShape> getBigDecimalShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all bigDecimals in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
bigdecimal
s that have a specific trait.
-
getBigIntegerShapes
public java.util.Set<BigIntegerShape> getBigIntegerShapes()
Gets an immutable set of all bigIntegers in the Model.- Returns:
- Returns the Set of
bigIntegers
s.
-
getBigIntegerShapesWithTrait
public java.util.Set<BigIntegerShape> getBigIntegerShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all bigIntegers in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
bigIntegers
s that have a specific trait.
-
getBlobShapes
public java.util.Set<BlobShape> getBlobShapes()
Gets an immutable set of all blobs in the Model.- Returns:
- Returns the Set of
blob
s.
-
getBlobShapesWithTrait
public java.util.Set<BlobShape> getBlobShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all blobs in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
blob
s that have a specific trait.
-
getBooleanShapes
public java.util.Set<BooleanShape> getBooleanShapes()
Gets an immutable set of all booleans in the Model.- Returns:
- Returns the Set of
boolean
s.
-
getBooleanShapesWithTrait
public java.util.Set<BooleanShape> getBooleanShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all booleans in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
boolean
s that have a specific trait.
-
getByteShapes
public java.util.Set<ByteShape> getByteShapes()
Gets an immutable set of all bytes in the Model.- Returns:
- Returns the Set of
byte
s.
-
getByteShapesWithTrait
public java.util.Set<ByteShape> getByteShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all bytes in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
byte
s that have a specific trait.
-
getDocumentShapes
public java.util.Set<DocumentShape> getDocumentShapes()
Gets an immutable set of all documents in the Model.- Returns:
- Returns the Set of
document
s.
-
getDocumentShapesWithTrait
public java.util.Set<DocumentShape> getDocumentShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all documents in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
document
s that have a specific trait.
-
getDoubleShapes
public java.util.Set<DoubleShape> getDoubleShapes()
Gets an immutable set of all doubles in the Model.- Returns:
- Returns the Set of
double
s.
-
getDoubleShapesWithTrait
public java.util.Set<DoubleShape> getDoubleShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all doubles in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
double
s that have a specific trait.
-
getFloatShapes
public java.util.Set<FloatShape> getFloatShapes()
Gets an immutable set of all floats in the Model.- Returns:
- Returns the Set of
float
s.
-
getFloatShapesWithTrait
public java.util.Set<FloatShape> getFloatShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all floats in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
float
s that have a specific trait.
-
getIntegerShapes
public java.util.Set<IntegerShape> getIntegerShapes()
Gets an immutable set of all integers in the Model.- Returns:
- Returns the Set of
integer
s.
-
getIntegerShapesWithTrait
public java.util.Set<IntegerShape> getIntegerShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all integers in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
integer
s that have a specific trait.
-
getIntEnumShapes
public java.util.Set<IntEnumShape> getIntEnumShapes()
Gets an immutable set of all intEnums in the Model.- Returns:
- Returns the Set of
intEnum
s.
-
getIntEnumShapesWithTrait
public java.util.Set<IntEnumShape> getIntEnumShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all intEnums in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
intEnum
s that have a specific trait.
-
getListShapes
public java.util.Set<ListShape> getListShapes()
Gets an immutable set of all lists in the Model.- Returns:
- Returns the Set of
list
s.
-
getListShapesWithTrait
public java.util.Set<ListShape> getListShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all lists in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
list
s that have a specific trait.
-
getLongShapes
public java.util.Set<LongShape> getLongShapes()
Gets an immutable set of all longs in the Model.- Returns:
- Returns the Set of
long
s.
-
getLongShapesWithTrait
public java.util.Set<LongShape> getLongShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all longs in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
long
s that have a specific trait.
-
getMapShapes
public java.util.Set<MapShape> getMapShapes()
Gets an immutable set of all maps in the Model.- Returns:
- Returns the Set of
map
s.
-
getMapShapesWithTrait
public java.util.Set<MapShape> getMapShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all maps in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
map
s that have a specific trait.
-
getMemberShapes
public java.util.Set<MemberShape> getMemberShapes()
Gets an immutable set of all members in the Model.- Returns:
- Returns the Set of
member
s.
-
getMemberShapesWithTrait
public java.util.Set<MemberShape> getMemberShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all members in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
member
s that have a specific trait.
-
getOperationShapes
public java.util.Set<OperationShape> getOperationShapes()
Gets an immutable set of all operations in the Model.- Returns:
- Returns the Set of
operation
s.
-
getOperationShapesWithTrait
public java.util.Set<OperationShape> getOperationShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all operations in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
operation
s that have a specific trait.
-
getResourceShapes
public java.util.Set<ResourceShape> getResourceShapes()
Gets an immutable set of all resources in the Model.- Returns:
- Returns the Set of
resource
s.
-
getResourceShapesWithTrait
public java.util.Set<ResourceShape> getResourceShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all resources in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
resource
s that have a specific trait.
-
getServiceShapes
public java.util.Set<ServiceShape> getServiceShapes()
Gets an immutable set of all services in the Model.- Returns:
- Returns the Set of
service
s.
-
getServiceShapesWithTrait
public java.util.Set<ServiceShape> getServiceShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all services in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
service
s that have a specific trait.
-
getSetShapes
@Deprecated public java.util.Set<SetShape> getSetShapes()
Deprecated.Gets an immutable set of all sets in the Model.- Returns:
- Returns the Set of
set
s.
-
getSetShapesWithTrait
@Deprecated public java.util.Set<SetShape> getSetShapesWithTrait(java.lang.Class<? extends Trait> trait)
Deprecated.Gets an immutable set of all sets in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
set
s that have a specific trait.
-
getShortShapes
public java.util.Set<ShortShape> getShortShapes()
Gets an immutable set of all shorts in the Model.- Returns:
- Returns the Set of
short
s.
-
getShortShapesWithTrait
public java.util.Set<ShortShape> getShortShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all shorts in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
short
s that have a specific trait.
-
getStringShapes
public java.util.Set<StringShape> getStringShapes()
Gets an immutable set of all strings in the Model.- Returns:
- Returns the Set of
string
s.
-
getStringShapesWithTrait
public java.util.Set<StringShape> getStringShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all strings in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
string
s that have a specific trait.
-
getEnumShapes
public java.util.Set<EnumShape> getEnumShapes()
Gets an immutable set of all enums in the Model.- Returns:
- Returns the Set of
enum
s.
-
getEnumShapesWithTrait
public java.util.Set<EnumShape> getEnumShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all enums in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
enum
s that have a specific trait.
-
getStructureShapes
public java.util.Set<StructureShape> getStructureShapes()
Gets an immutable set of all structures in the Model.- Returns:
- Returns the Set of
structure
s.
-
getStructureShapesWithTrait
public java.util.Set<StructureShape> getStructureShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all structures in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
structure
s that have a specific trait.
-
getTimestampShapes
public java.util.Set<TimestampShape> getTimestampShapes()
Gets an immutable set of all timestamps in the Model.- Returns:
- Returns the Set of
timestamp
s.
-
getTimestampShapesWithTrait
public java.util.Set<TimestampShape> getTimestampShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all timestamps in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
timestamp
s that have a specific trait.
-
getUnionShapes
public java.util.Set<UnionShape> getUnionShapes()
Gets an immutable set of all unions in the Model.- Returns:
- Returns the Set of
union
s.
-
getUnionShapesWithTrait
public java.util.Set<UnionShape> getUnionShapesWithTrait(java.lang.Class<? extends Trait> trait)
Gets an immutable set of all unions in the Model that have a specific trait.- Parameters:
trait
- The exact trait class to look for on shapes.- Returns:
- Returns the set of
union
s that have a specific trait.
-
getAppliedTraits
public java.util.Set<ShapeId> getAppliedTraits()
Gets a set of every trait shape ID that is used in the model.- Returns:
- Returns the shape IDs of traits used in the model.
-
isTraitApplied
public boolean isTraitApplied(java.lang.Class<? extends Trait> trait)
Returns true if the given trait shape ID was used in the model.- Parameters:
trait
- The trait class to check.- Returns:
- Returns true if the trait was used in the model.
-
getShape
public java.util.Optional<Shape> getShape(ShapeId id)
- Parameters:
id
- Shape to retrieve by ID.- Returns:
- Returns the optional shape.
-
expectShape
public Shape expectShape(ShapeId id)
- Parameters:
id
- Shape to retrieve by ID.- Returns:
- Returns the shape.
- Throws:
ExpectationNotMetException
- if the shape is not found.
-
expectShape
public <T extends Shape> T expectShape(ShapeId id, java.lang.Class<T> type)
Attempts to retrieve aShape
byShapeId
and throws if not found or if the shape is not of the expected type.- Type Parameters:
T
- Expected shape type.- Parameters:
id
- Shape to retrieve by ID.type
- Shape type to expect and convert to.- Returns:
- Returns the shape.
- Throws:
ExpectationNotMetException
- if the shape is not found or is not the expected type.
-
shapes
public java.util.stream.Stream<Shape> shapes()
Gets a stream ofShape
s in the index.- Returns:
- Returns a stream of shapes.
-
shapes
public <T extends Shape> java.util.stream.Stream<T> shapes(java.lang.Class<T> shapeType)
Gets a stream of shapes in the index of a specific typeT
.The provided shapeType class must exactly match the class of a shape in the model in order to be returned from this method; that is, the provided class must be a concrete subclass of
Shape
and not an abstract class likeNumberShape
.- Type Parameters:
T
- Shape type to stream from the index.- Parameters:
shapeType
- Shape typeT
to retrieve.- Returns:
- A stream of shapes of
T
matchingshapeType
.
-
toSet
public <T extends Shape> java.util.Set<T> toSet(java.lang.Class<T> shapeType)
Gets an immutable Set of shapes of a specific type.- Type Parameters:
T
- Shape type to get from the index.- Parameters:
shapeType
- Type of shape to get a set of.- Returns:
- Returns an unmodifiable set of shapes.
-
toSet
public java.util.Set<Shape> toSet()
Converts the model to an immutable Set of shapes.- Returns:
- Returns an unmodifiable set of shapes.
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toBuilder
public Model.Builder toBuilder()
Description copied from interface:ToSmithyBuilder
Take this object and create a builder that contains all of the current property values of this object.- Specified by:
toBuilder
in interfaceToSmithyBuilder<Model>
- Returns:
- a builder for type T
-
getKnowledge
@Deprecated public <T extends KnowledgeIndex> T getKnowledge(java.lang.Class<T> type)
Deprecated.This method is deprecated. Use theof
method of theKnowledgeIndex
you wish to create instead.- Type Parameters:
T
- The type of knowledge index to retrieve.- Parameters:
type
- Type of knowledge index to retrieve.- Returns:
- Returns the computed knowledge index.
-
getKnowledge
public <T extends KnowledgeIndex> T getKnowledge(java.lang.Class<T> type, java.util.function.Function<Model,T> constructor)
Gets a computed "knowledge index" of a specific type for the model and caches it for subsequent retrieval.This method should not typically be called directly because KnowledgeIndex classes should all provide a public static
of
method that accepts aModel
and returns an instance of the index by invokinggetKnowledge
.If a
KnowledgeIndex
of the given type has not yet been computed, one will be created using the providedconstructor
function that accepts aModel
. Computed knowledge indexes are cached and returned on subsequent retrievals.- Type Parameters:
T
- The type of knowledge index to retrieve.- Parameters:
type
- Type of knowledge index to retrieve.constructor
- The method used to createtype
.- Returns:
- Returns the computed knowledge index.
-
-