public abstract class AbstractTrait extends java.lang.Object implements Trait
This implementation provides an equals(java.lang.Object)
and hashCode()
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's ToNode
representation.
Modifier and Type | Class and Description |
---|---|
static class |
AbstractTrait.Provider
Basic provider implementation that returns the name of the
provided trait.
|
Constructor and Description |
---|
AbstractTrait(ShapeId id,
FromSourceLocation sourceLocation) |
Modifier and Type | Method and 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 a
Node . |
ShapeId |
toShapeId()
Gets the shape ID of the trait.
|
java.lang.String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
flatMapStream, getIdiomaticTraitName, getIdiomaticTraitName, makeAbsoluteName, makeAbsoluteName
public AbstractTrait(ShapeId id, FromSourceLocation sourceLocation)
id
- ID of the trait.sourceLocation
- Where the trait was defined.public final ShapeId toShapeId()
Trait
public final SourceLocation getSourceLocation()
FromSourceLocation
getSourceLocation
in interface FromSourceLocation
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public final Node toNode()
ToNode
Node
.protected abstract Node createNode()