Class Shape
java.lang.Object
software.amazon.smithy.model.shapes.Shape
- All Implemented Interfaces:
Comparable<Shape>,FromSourceLocation,ToShapeId,Tagged
- Direct Known Subclasses:
CollectionShape,EntityShape,MapShape,MemberShape,OperationShape,SimpleShape,StructureShape,UnionShape
public abstract class Shape
extends Object
implements FromSourceLocation, Tagged, ToShapeId, Comparable<Shape>
A
Shape defines a model component.
A Shape may 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 Summary
Modifier and TypeMethodDescriptionabstract <R> Raccept(ShapeVisitor<R> cases) Dispatches the shape to the appropriateShapeVisitormethod.intbooleanfinal <T extends Trait>
TexpectTrait(Class<T> traitClass) Gets specificTraitby class from the shape or throws if not found.findMemberTrait(Model model, String traitName) Gets a trait from the member shape or from the shape targeted by the member.Attempts to find a trait applied to the shape by ID.Attempts to find a trait applied to the shape by name.Gets all of the traits attached to the shape.final ShapeIdgetId()Get theShapeIdof the shape.getMemberTrait(Model model, Class<T> trait) Gets a trait from the member shape or from the shape targeted by the member.final SourceLocationGets the source location of a value.getTags()Gets the tags applied to an object.Attempt to retrieve a specificTraitby class from the shape.abstract ShapeTypegetType()Gets the type of the shape.inthashCode()booleanChecks if the shape has a specific trait by class.booleanChecks if the shape has a specific trait by name.booleanChecks if the shape has a specific trait by name.final booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanfinal booleanmembers()Gets all of 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.final StringtoString()
-
Method Details
-
shapeToBuilder
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.
-
getType
Gets the type of the shape.- Returns:
- Returns the type;
-
accept
Dispatches the shape to the appropriateShapeVisitormethod.- Type Parameters:
R- Return type of the accept.- Parameters:
cases- NeighborVisitor to use.- Returns:
- Returns the result.
-
getId
Get theShapeIdof the shape.- Returns:
- Returns the shape ID.
-
hasTrait
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.
-
hasTrait
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.
-
hasTrait
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.
-
findTrait
Attempts to find a trait applied to the shape by name.- Parameters:
id- The trait shape ID.- Returns:
- Returns the optionally found trait.
-
findTrait
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.
-
getTrait
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.
-
expectTrait
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.
-
getAllTraits
Gets all of the traits attached to the shape.- Returns:
- Returns the attached traits.
-
getMemberTrait
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:
-
findMemberTrait
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:
-
asBigDecimalShape
- Returns:
- Optionally returns the shape as a
BigDecimalShape.
-
asBigIntegerShape
- Returns:
- Optionally returns the shape as a
BigIntegerShape.
-
asBlobShape
- Returns:
- Optionally returns the shape as a
BlobShape.
-
asBooleanShape
- Returns:
- Optionally returns the shape as a
BooleanShape.
-
asByteShape
- Returns:
- Optionally returns the shape as a
ByteShape.
-
asShortShape
- Returns:
- Optionally returns the shape as a
ShortShape.
-
asFloatShape
- Returns:
- Optionally returns the shape as a
FloatShape.
-
asDocumentShape
- Returns:
- Optionally returns the shape as a
DocumentShape.
-
asDoubleShape
- Returns:
- Optionally returns the shape as a
DoubleShape.
-
asIntegerShape
- Returns:
- Optionally returns the shape as a
IntegerShape.
-
asListShape
- Returns:
- Optionally returns the shape as a
ListShape.
-
asSetShape
- Returns:
- Optionally returns the shape as a
SetShape.
-
asLongShape
- Returns:
- Optionally returns the shape as a
LongShape.
-
asMapShape
- Returns:
- Optionally returns the shape as a
MapShape.
-
asMemberShape
- Returns:
- Optionally returns the shape as a
MemberShape.
-
asOperationShape
- Returns:
- Optionally returns the shape as an
OperationShape.
-
asResourceShape
- Returns:
- Optionally returns the shape as a
ResourceShape.
-
asServiceShape
- Returns:
- Optionally returns the shape as a
ServiceShape.
-
asStringShape
- Returns:
- Optionally returns the shape as a
StringShape.
-
asStructureShape
- Returns:
- Optionally returns the shape as a
StructureShape.
-
asUnionShape
- Returns:
- Optionally returns the shape as a
UnionShape.
-
asTimestampShape
- Returns:
- Optionally returns the shape as a
TimestampShape.
-
isBigDecimalShape
public final boolean isBigDecimalShape()- Returns:
- Returns true if the shape is a
BigDecimalShapeshape.
-
isBigIntegerShape
public final boolean isBigIntegerShape()- Returns:
- Returns true if the shape is a
BigIntegerShapeshape.
-
isBlobShape
public final boolean isBlobShape()- Returns:
- Returns true if the shape is a
BlobShapeshape.
-
isBooleanShape
public final boolean isBooleanShape()- Returns:
- Returns true if the shape is a
BooleanShapeshape.
-
isByteShape
public final boolean isByteShape()- Returns:
- Returns true if the shape is a
ByteShapeshape.
-
isShortShape
public final boolean isShortShape()- Returns:
- Returns true if the shape is a
ShortShapeshape.
-
isFloatShape
public final boolean isFloatShape()- Returns:
- Returns true if the shape is a
FloatShapeshape.
-
isDocumentShape
public final boolean isDocumentShape()- Returns:
- Returns true if the shape is an
DocumentShapeshape.
-
isDoubleShape
public final boolean isDoubleShape()- Returns:
- Returns true if the shape is an
DoubleShapeshape.
-
isListShape
public final boolean isListShape()- Returns:
- Returns true if the shape is a
ListShapeshape.
-
isSetShape
public final boolean isSetShape()- Returns:
- Returns true if the shape is a
SetShapeshape.
-
isIntegerShape
public final boolean isIntegerShape()- Returns:
- Returns true if the shape is a
IntegerShapeshape.
-
isLongShape
public final boolean isLongShape()- Returns:
- Returns true if the shape is a
LongShapeshape.
-
isMapShape
public final boolean isMapShape()- Returns:
- Returns true if the shape is a
MapShapeshape.
-
isMemberShape
public final boolean isMemberShape()- Returns:
- Returns true if the shape is a
MemberShapeshape.
-
isOperationShape
public final boolean isOperationShape()- Returns:
- Returns true if the shape is an
OperationShapeshape.
-
isResourceShape
public final boolean isResourceShape()- Returns:
- Returns true if the shape is a
ResourceShapeshape.
-
isServiceShape
public final boolean isServiceShape()- Returns:
- Returns true if the shape is a
ServiceShapeshape.
-
isStringShape
public final boolean isStringShape()- Returns:
- Returns true if the shape is a
StringShapeshape.
-
isStructureShape
public final boolean isStructureShape()- Returns:
- Returns true if the shape is a
StructureShapeshape.
-
isUnionShape
public final boolean isUnionShape()- Returns:
- Returns true if the shape is a
UnionShapeshape.
-
isTimestampShape
public final boolean isTimestampShape()- Returns:
- Returns true if the shape is a
TimestampShapeshape.
-
members
Gets all of the members contained in the shape.- Returns:
- Returns the members contained in the shape (if any).
-
toShapeId
-
getTags
Description copied from interface:TaggedGets the tags applied to an object. -
getSourceLocation
Description copied from interface:FromSourceLocationGets the source location of a value.- Specified by:
getSourceLocationin interfaceFromSourceLocation- Returns:
- Returns the source location of the value.
-
compareTo
- Specified by:
compareToin interfaceComparable<Shape>
-
toString
-
hashCode
public int hashCode() -
equals
-