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'sToNoderepresentation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractTrait.ProviderBasic 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 NodecreateNode()The result of toNode is used for hashCodes and equality.booleanequals(java.lang.Object other)SourceLocationgetSourceLocation()Gets the source location of a value.inthashCode()NodetoNode()Converts a value to aNode.ShapeIdtoShapeId()Gets the shape ID of the trait.java.lang.StringtoString()
-
-
-
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:TraitGets the shape ID of the trait.
-
getSourceLocation
public final SourceLocation getSourceLocation()
Description copied from interface:FromSourceLocationGets the source location of a value.- Specified by:
getSourceLocationin interfaceFromSourceLocation- Returns:
- Returns the source location of the value.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toNode
public final Node toNode()
Description copied from interface:ToNodeConverts 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.
-
-