Class Shape
- java.lang.Object
- 
- software.amazon.smithy.model.shapes.Shape
 
- 
- All Implemented Interfaces:
- java.lang.Comparable<Shape>,- FromSourceLocation,- ToShapeId,- Tagged
 - Direct Known Subclasses:
- CollectionShape,- EntityShape,- MapShape,- MemberShape,- OperationShape,- SimpleShape,- StructureShape,- UnionShape
 
 public abstract class Shape extends java.lang.Object implements FromSourceLocation, Tagged, ToShapeId, java.lang.Comparable<Shape> AShapedefines a model component.A Shapemay have an arbitrary number of typed traits attached to it, allowing additional information to be associated with the shape.Shape does implement Comparable, but comparisons are based solely on the ShapeId of the shape. This assumes that shapes are being compared in the context of a Model that forbids shape ID conflicts.
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract <R> Raccept(ShapeVisitor<R> visitor)Dispatches the shape to the appropriateShapeVisitormethod.java.util.Optional<BigDecimalShape>asBigDecimalShape()java.util.Optional<BigIntegerShape>asBigIntegerShape()java.util.Optional<BlobShape>asBlobShape()java.util.Optional<BooleanShape>asBooleanShape()java.util.Optional<ByteShape>asByteShape()java.util.Optional<DocumentShape>asDocumentShape()java.util.Optional<DoubleShape>asDoubleShape()java.util.Optional<EnumShape>asEnumShape()java.util.Optional<FloatShape>asFloatShape()java.util.Optional<IntegerShape>asIntegerShape()java.util.Optional<IntEnumShape>asIntEnumShape()java.util.Optional<ListShape>asListShape()java.util.Optional<LongShape>asLongShape()java.util.Optional<MapShape>asMapShape()java.util.Optional<MemberShape>asMemberShape()java.util.Optional<OperationShape>asOperationShape()java.util.Optional<ResourceShape>asResourceShape()java.util.Optional<ServiceShape>asServiceShape()java.util.Optional<SetShape>asSetShape()Deprecated.java.util.Optional<ShortShape>asShortShape()java.util.Optional<StringShape>asStringShape()java.util.Optional<StructureShape>asStructureShape()java.util.Optional<TimestampShape>asTimestampShape()java.util.Optional<UnionShape>asUnionShape()intcompareTo(Shape other)booleanequals(java.lang.Object o)<T extends Trait>
 TexpectTrait(java.lang.Class<T> traitClass)Gets specificTraitby class from the shape or throws if not found.java.util.Optional<Trait>findMemberTrait(Model model, java.lang.String traitName)Gets a trait from the member shape or from the shape targeted by the member.java.util.Optional<Trait>findTrait(java.lang.String id)Attempts to find a trait applied to the shape by ID.java.util.Optional<Trait>findTrait(ShapeId id)Attempts to find a trait applied to the shape by name.java.util.Map<java.lang.String,MemberShape>getAllMembers()Gets the members of the shape, including mixin members.java.util.Map<ShapeId,Trait>getAllTraits()Gets all of the traits attached to the shape.ShapeIdgetId()Get theShapeIdof the shape.java.util.Map<ShapeId,Trait>getIntroducedTraits()Gets the traits introduced by the shape and not inherited from mixins.java.util.Optional<MemberShape>getMember(java.lang.String name)Get a specific member by name.java.util.List<java.lang.String>getMemberNames()Returns an ordered list of member names based on the order they are defined in the model, including mixin members.<T extends Trait>
 java.util.Optional<T>getMemberTrait(Model model, java.lang.Class<T> trait)Gets a trait from the member shape or from the shape targeted by the member.java.util.Set<ShapeId>getMixins()Get an ordered set of mixins attached to the shape.protected MemberShape[]getRequiredMembers(AbstractShapeBuilder<?,?> builder, java.lang.String... requiredMembersNames)SourceLocationgetSourceLocation()Gets the source location of a value.java.util.List<java.lang.String>getTags()Gets the tags applied to an object.<T extends Trait>
 java.util.Optional<T>getTrait(java.lang.Class<T> traitClass)Attempt to retrieve a specificTraitby class from the shape.abstract ShapeTypegetType()Gets the type of the shape.inthashCode()booleanhasTrait(java.lang.Class<? extends Trait> traitClass)Checks if the shape has a specific trait by class.booleanhasTrait(java.lang.String id)Checks if the shape has a specific trait by name.booleanhasTrait(ShapeId id)Checks if the shape has a specific trait by name.booleanisBigDecimalShape()booleanisBigIntegerShape()booleanisBlobShape()booleanisBooleanShape()booleanisByteShape()booleanisDocumentShape()booleanisDoubleShape()booleanisEnumShape()booleanisFloatShape()booleanisIntegerShape()booleanisIntEnumShape()booleanisListShape()booleanisLongShape()booleanisMapShape()booleanisMemberShape()booleanisOperationShape()booleanisResourceShape()booleanisServiceShape()booleanisSetShape()Deprecated.booleanisShortShape()booleanisStringShape()booleanisStructureShape()booleanisTimestampShape()booleanisUnionShape()java.util.Collection<MemberShape>members()Gets all the members contained in the shape.static <B extends AbstractShapeBuilder<B,S>,S extends Shape>
 BshapeToBuilder(S shape)Converts a shape, potentially of an unknown concrete type, into a Shape builder.ShapeIdtoShapeId()java.lang.StringtoString()protected voidvalidateMemberShapeIds()protected voidvalidateMixins(java.util.Map<ShapeId,Shape> mixins, java.util.Map<ShapeId,Trait> introducedTraits)
 
- 
- 
- 
Method Detail- 
validateMixinsprotected void validateMixins(java.util.Map<ShapeId,Shape> mixins, java.util.Map<ShapeId,Trait> introducedTraits) 
 - 
getRequiredMembersprotected MemberShape[] getRequiredMembers(AbstractShapeBuilder<?,?> builder, java.lang.String... requiredMembersNames) 
 - 
validateMemberShapeIdsprotected final void validateMemberShapeIds() 
 - 
shapeToBuilderpublic static <B extends AbstractShapeBuilder<B,S>,S extends Shape> B shapeToBuilder(S shape) Converts a shape, potentially of an unknown concrete type, into a Shape builder.- Type Parameters:
- B- Shape builder to create.
- S- Shape that is being converted to a builder.
- Parameters:
- shape- Shape to create a builder from.
- Returns:
- Returns a shape fro the given shape.
 
 - 
getTypepublic abstract ShapeType getType() Gets the type of the shape.- Returns:
- Returns the type;
 
 - 
acceptpublic abstract <R> R accept(ShapeVisitor<R> visitor) Dispatches the shape to the appropriateShapeVisitormethod.- Type Parameters:
- R- Return type of the accept.
- Parameters:
- visitor- ShapeVisitor to use.
- Returns:
- Returns the result.
 
 - 
hasTraitpublic boolean hasTrait(java.lang.String id) Checks if the shape has a specific trait by name.Relative shape IDs are assumed to refer to the "smithy.api" namespace. - Parameters:
- id- The possibly relative trait ID.
- Returns:
- Returns true if the shape has the given trait.
 
 - 
hasTraitpublic boolean hasTrait(ShapeId id) Checks if the shape has a specific trait by name.- Parameters:
- id- The fully-qualified trait ID.
- Returns:
- Returns true if the shape has the given trait.
 
 - 
hasTraitpublic boolean hasTrait(java.lang.Class<? extends Trait> traitClass) Checks if the shape has a specific trait by class.- Parameters:
- traitClass- Trait class to check.
- Returns:
- Returns true if the shape has the given trait.
 
 - 
findTraitpublic java.util.Optional<Trait> findTrait(ShapeId id) Attempts to find a trait applied to the shape by name.- Parameters:
- id- The trait shape ID.
- Returns:
- Returns the optionally found trait.
 
 - 
findTraitpublic java.util.Optional<Trait> findTrait(java.lang.String id) Attempts to find a trait applied to the shape by ID.Relative shape IDs are assumed to refer to the "smithy.api" namespace. - Parameters:
- id- The trait ID.
- Returns:
- Returns the optionally found trait.
 
 - 
getTraitpublic final <T extends Trait> java.util.Optional<T> getTrait(java.lang.Class<T> traitClass) Attempt to retrieve a specificTraitby class from the shape.The first trait instance found matching the given type is returned. - Type Parameters:
- T- The instance of the trait to retrieve.
- Parameters:
- traitClass- Trait class to retrieve.
- Returns:
- Returns the matching trait.
 
 - 
expectTraitpublic final <T extends Trait> T expectTrait(java.lang.Class<T> traitClass) Gets specificTraitby class from the shape or throws if not found.- Type Parameters:
- T- The instance of the trait to retrieve.
- Parameters:
- traitClass- Trait class to retrieve.
- Returns:
- Returns the matching trait.
- Throws:
- ExpectationNotMetException- if the trait cannot be found.
 
 - 
getAllTraitspublic final java.util.Map<ShapeId,Trait> getAllTraits() Gets all of the traits attached to the shape.- Returns:
- Returns the attached traits.
 
 - 
getMemberTraitpublic <T extends Trait> java.util.Optional<T> getMemberTrait(Model model, java.lang.Class<T> trait) Gets a trait from the member shape or from the shape targeted by the member.If the shape is not a member, then the method functions the same as getTrait(Class).- Type Parameters:
- T- Trait type to get.
- Parameters:
- model- Model used to find member targets.
- trait- Trait type to get.
- Returns:
- Returns the optionally found trait on the shape or member.
- See Also:
- getTrait(Class)
 
 - 
findMemberTraitpublic java.util.Optional<Trait> findMemberTrait(Model model, java.lang.String traitName) Gets a trait from the member shape or from the shape targeted by the member.If the shape is not a member, then the method functions the same as findTrait(String).- Parameters:
- model- Model used to find member targets.
- traitName- Trait name to get.
- Returns:
- Returns the optionally found trait on the shape or member.
- See Also:
- findTrait(String)
 
 - 
asBigDecimalShapepublic java.util.Optional<BigDecimalShape> asBigDecimalShape() - Returns:
- Optionally returns the shape as a BigDecimalShape.
 
 - 
asBigIntegerShapepublic java.util.Optional<BigIntegerShape> asBigIntegerShape() - Returns:
- Optionally returns the shape as a BigIntegerShape.
 
 - 
asBlobShapepublic java.util.Optional<BlobShape> asBlobShape() - Returns:
- Optionally returns the shape as a BlobShape.
 
 - 
asBooleanShapepublic java.util.Optional<BooleanShape> asBooleanShape() - Returns:
- Optionally returns the shape as a BooleanShape.
 
 - 
asByteShapepublic java.util.Optional<ByteShape> asByteShape() - Returns:
- Optionally returns the shape as a ByteShape.
 
 - 
asShortShapepublic java.util.Optional<ShortShape> asShortShape() - Returns:
- Optionally returns the shape as a ShortShape.
 
 - 
asFloatShapepublic java.util.Optional<FloatShape> asFloatShape() - Returns:
- Optionally returns the shape as a FloatShape.
 
 - 
asDocumentShapepublic java.util.Optional<DocumentShape> asDocumentShape() - Returns:
- Optionally returns the shape as a DocumentShape.
 
 - 
asDoubleShapepublic java.util.Optional<DoubleShape> asDoubleShape() - Returns:
- Optionally returns the shape as a DoubleShape.
 
 - 
asIntegerShapepublic java.util.Optional<IntegerShape> asIntegerShape() - Returns:
- Optionally returns the shape as a IntegerShape.
 
 - 
asIntEnumShapepublic java.util.Optional<IntEnumShape> asIntEnumShape() - Returns:
- Optionally returns the shape as a IntEnumShape.
 
 - 
asListShapepublic java.util.Optional<ListShape> asListShape() - Returns:
- Optionally returns the shape as a ListShape.
 
 - 
asSetShape@Deprecated public java.util.Optional<SetShape> asSetShape() Deprecated.- Returns:
- Optionally returns the shape as a SetShape.
 
 - 
asLongShapepublic java.util.Optional<LongShape> asLongShape() - Returns:
- Optionally returns the shape as a LongShape.
 
 - 
asMapShapepublic java.util.Optional<MapShape> asMapShape() - Returns:
- Optionally returns the shape as a MapShape.
 
 - 
asMemberShapepublic java.util.Optional<MemberShape> asMemberShape() - Returns:
- Optionally returns the shape as a MemberShape.
 
 - 
asOperationShapepublic java.util.Optional<OperationShape> asOperationShape() - Returns:
- Optionally returns the shape as an OperationShape.
 
 - 
asResourceShapepublic java.util.Optional<ResourceShape> asResourceShape() - Returns:
- Optionally returns the shape as a ResourceShape.
 
 - 
asServiceShapepublic java.util.Optional<ServiceShape> asServiceShape() - Returns:
- Optionally returns the shape as a ServiceShape.
 
 - 
asStringShapepublic java.util.Optional<StringShape> asStringShape() - Returns:
- Optionally returns the shape as a StringShape.
 
 - 
asEnumShapepublic java.util.Optional<EnumShape> asEnumShape() - Returns:
- Optionally returns the shape as a EnumShape.
 
 - 
asStructureShapepublic java.util.Optional<StructureShape> asStructureShape() - Returns:
- Optionally returns the shape as a StructureShape.
 
 - 
asUnionShapepublic java.util.Optional<UnionShape> asUnionShape() - Returns:
- Optionally returns the shape as a UnionShape.
 
 - 
asTimestampShapepublic java.util.Optional<TimestampShape> asTimestampShape() - Returns:
- Optionally returns the shape as a TimestampShape.
 
 - 
isBigDecimalShapepublic final boolean isBigDecimalShape() - Returns:
- Returns true if the shape is a BigDecimalShapeshape.
 
 - 
isBigIntegerShapepublic final boolean isBigIntegerShape() - Returns:
- Returns true if the shape is a BigIntegerShapeshape.
 
 - 
isBlobShapepublic final boolean isBlobShape() - Returns:
- Returns true if the shape is a BlobShapeshape.
 
 - 
isBooleanShapepublic final boolean isBooleanShape() - Returns:
- Returns true if the shape is a BooleanShapeshape.
 
 - 
isByteShapepublic final boolean isByteShape() - Returns:
- Returns true if the shape is a ByteShapeshape.
 
 - 
isShortShapepublic final boolean isShortShape() - Returns:
- Returns true if the shape is a ShortShapeshape.
 
 - 
isFloatShapepublic final boolean isFloatShape() - Returns:
- Returns true if the shape is a FloatShapeshape.
 
 - 
isDocumentShapepublic final boolean isDocumentShape() - Returns:
- Returns true if the shape is an DocumentShapeshape.
 
 - 
isDoubleShapepublic final boolean isDoubleShape() - Returns:
- Returns true if the shape is an DoubleShapeshape.
 
 - 
isListShapepublic final boolean isListShape() - Returns:
- Returns true if the shape is a ListShapeshape.
 
 - 
isSetShape@Deprecated public final boolean isSetShape() Deprecated.- Returns:
- Returns true if the shape is a SetShapeshape.
 
 - 
isIntegerShapepublic final boolean isIntegerShape() - Returns:
- Returns true if the shape is a IntegerShapeshape.
 
 - 
isIntEnumShapepublic final boolean isIntEnumShape() - Returns:
- Returns true if the shape is a IntEnumShapeshape.
 
 - 
isLongShapepublic final boolean isLongShape() - Returns:
- Returns true if the shape is a LongShapeshape.
 
 - 
isMapShapepublic final boolean isMapShape() - Returns:
- Returns true if the shape is a MapShapeshape.
 
 - 
isMemberShapepublic final boolean isMemberShape() - Returns:
- Returns true if the shape is a MemberShapeshape.
 
 - 
isOperationShapepublic final boolean isOperationShape() - Returns:
- Returns true if the shape is an OperationShapeshape.
 
 - 
isResourceShapepublic final boolean isResourceShape() - Returns:
- Returns true if the shape is a ResourceShapeshape.
 
 - 
isServiceShapepublic final boolean isServiceShape() - Returns:
- Returns true if the shape is a ServiceShapeshape.
 
 - 
isStringShapepublic final boolean isStringShape() - Returns:
- Returns true if the shape is a StringShapeshape.
 
 - 
isEnumShapepublic final boolean isEnumShape() - Returns:
- Returns true if the shape is an EnumShapeshape.
 
 - 
isStructureShapepublic final boolean isStructureShape() - Returns:
- Returns true if the shape is a StructureShapeshape.
 
 - 
isUnionShapepublic final boolean isUnionShape() - Returns:
- Returns true if the shape is a UnionShapeshape.
 
 - 
isTimestampShapepublic final boolean isTimestampShape() - Returns:
- Returns true if the shape is a TimestampShapeshape.
 
 - 
memberspublic java.util.Collection<MemberShape> members() Gets all the members contained in the shape.- Returns:
- Returns the members contained in the shape (if any).
 
 - 
getMemberpublic java.util.Optional<MemberShape> getMember(java.lang.String name) Get a specific member by name.Shapes with no members return an empty Optional. - Parameters:
- name- Name of the member to retrieve.
- Returns:
- Returns the optional member.
 
 - 
getAllMemberspublic java.util.Map<java.lang.String,MemberShape> getAllMembers() Gets the members of the shape, including mixin members.- Returns:
- Returns the immutable member map.
 
 - 
getMemberNamespublic java.util.List<java.lang.String> getMemberNames() Returns an ordered list of member names based on the order they are defined in the model, including mixin members.The order in which map key and value members are returned might not match the order in which they were defined in the model because their ordering is insignificant. - Returns:
- Returns an immutable list of member names.
 
 - 
getMixinspublic java.util.Set<ShapeId> getMixins() Get an ordered set of mixins attached to the shape.- Returns:
- Returns the ordered mixin shape IDs.
 
 - 
getIntroducedTraitspublic java.util.Map<ShapeId,Trait> getIntroducedTraits() Gets the traits introduced by the shape and not inherited from mixins.- Returns:
- Returns the introduced traits.
 
 - 
toShapeIdpublic ShapeId toShapeId() 
 - 
getTagspublic final java.util.List<java.lang.String> getTags() Description copied from interface:TaggedGets the tags applied to an object.
 - 
getSourceLocationpublic final SourceLocation getSourceLocation() Description copied from interface:FromSourceLocationGets the source location of a value.- Specified by:
- getSourceLocationin interface- FromSourceLocation
- Returns:
- Returns the source location of the value.
 
 - 
compareTopublic int compareTo(Shape other) - Specified by:
- compareToin interface- java.lang.Comparable<Shape>
 
 - 
toStringpublic final java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- java.lang.Object
 
 - 
equalspublic boolean equals(java.lang.Object o) - Overrides:
- equalsin class- java.lang.Object
 
 
- 
 
-