Class AbstractTrait
- java.lang.Object
-
- software.amazon.smithy.model.traits.AbstractTrait
-
- All Implemented Interfaces:
FromSourceLocation
,ToNode
,ToShapeId
,Trait
- Direct Known Subclasses:
ArnReferenceTrait
,ArnTrait
,AuthDefinitionTrait
,AuthorizersTrait
,AuthTrait
,AwsProtocolTrait
,CfnResourceTrait
,ClientDiscoveredEndpointTrait
,ClientEndpointDiscoveryTrait
,CognitoUserPoolsTrait
,CorsTrait
,DefineConditionKeysTrait
,DeprecatedTrait
,DynamicTrait
,EndpointTrait
,EnumTrait
,ExamplesTrait
,ExternalDocumentationTrait
,HttpApiKeyAuthTrait
,HttpErrorTrait
,HttpRequestTestsTrait
,HttpResponseTestsTrait
,HttpTrait
,IdRefTrait
,IntegrationTrait
,LengthTrait
,MockIntegrationTrait
,PaginatedTrait
,ProtocolDefinitionTrait
,RangeTrait
,ReferencesTrait
,RetryableTrait
,ServiceTrait
,SigV4Trait
,StringListTrait
,StringTrait
,TraitDefinition
,WaitableTrait
,XmlNamespaceTrait
public abstract class AbstractTrait extends java.lang.Object implements Trait
Base implementation of traits.This implementation provides an
equals(java.lang.Object)
andhashCode()
that should work for most traits that extend from this base class. Note that equality for traits that extend from this type are not based on the concrete class, but rather the trait name and the trait'sToNode
representation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractTrait.Provider
Basic provider implementation that returns the name of the provided trait.
-
Constructor Summary
Constructors Constructor Description AbstractTrait(ShapeId id, FromSourceLocation sourceLocation)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Node
createNode()
The result of toNode is used for hashCodes and equality.boolean
equals(java.lang.Object other)
SourceLocation
getSourceLocation()
Gets the source location of a value.int
hashCode()
Node
toNode()
Converts a value to aNode
.ShapeId
toShapeId()
Gets the shape ID of the trait.java.lang.String
toString()
-
-
-
Constructor Detail
-
AbstractTrait
public AbstractTrait(ShapeId id, FromSourceLocation sourceLocation)
- Parameters:
id
- ID of the trait.sourceLocation
- Where the trait was defined.
-
-
Method Detail
-
toShapeId
public final ShapeId toShapeId()
Description copied from interface:Trait
Gets the shape ID of the trait.
-
getSourceLocation
public final SourceLocation getSourceLocation()
Description copied from interface:FromSourceLocation
Gets the source location of a value.- Specified by:
getSourceLocation
in interfaceFromSourceLocation
- Returns:
- Returns the source location of the value.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toNode
public final Node toNode()
Description copied from interface:ToNode
Converts a value to aNode
.
-
createNode
protected abstract Node createNode()
The result of toNode is used for hashCodes and equality. Subclasses must implement createNode to turn the trait into a Node. This is then cached for subsequent retrievals.- Returns:
- Returns the trait as a node.
-
-