Class Relationship
java.lang.Object
software.amazon.smithy.model.neighbor.Relationship
Represent a direct relationship between two shapes.
A relationship is a connection between two shapes. See
RelationshipType
for documentation on the possible
types of relationships.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Relationship
create
(Shape shape, RelationshipType relationshipType, Shape neighborShape) Constructs a valid shape relationship where the neighbor is present.static Relationship
createInvalid
(Shape shape, RelationshipType relationshipType, ShapeId neighborShapeId) Constructs an invalid shape relationship where the neighbor is not present.boolean
Gets the neighbor shape or throws if it doesn't exist.Gets the direction of the relationship.Gets the optional neighbor shape; the neighbor shape may be empty when the neighbor shape id was not in the model.Gets the shape id of the neighbor shape.Gets the relationship type.Gets the token that is used inSelector
expressions when referring to the relationship or an emptyOptional
if this relationship is not used in a selector.getShape()
Gets the starting shape in the relationship.int
hashCode()
toString()
-
Method Details
-
create
public static Relationship create(Shape shape, RelationshipType relationshipType, Shape neighborShape) Constructs a valid shape relationship where the neighbor is present.- Parameters:
shape
- The shape the relationship originates from.relationshipType
- The relationshipType of relationship.neighborShape
- The shape the relationship targets.- Returns:
- Returns the created Relationship.
-
createInvalid
public static Relationship createInvalid(Shape shape, RelationshipType relationshipType, ShapeId neighborShapeId) Constructs an invalid shape relationship where the neighbor is not present.- Parameters:
shape
- The shape the relationship originates from.relationshipType
- The relationshipType of relationship.neighborShapeId
- The shape the relationship targets.- Returns:
- Returns the created Relationship.
-
getShape
Gets the starting shape in the relationship.- Returns:
- Returns the shape the relationship is from.
-
getRelationshipType
Gets the relationship type.- Returns:
- Returns the relationship type.
-
getNeighborShapeId
Gets the shape id of the neighbor shape.- Returns:
- Returns the shape id of the neighbor shape.
-
getNeighborShape
Gets the optional neighbor shape; the neighbor shape may be empty when the neighbor shape id was not in the model.- Returns:
- Returns the optional neighbor shape.
-
expectNeighborShape
Gets the neighbor shape or throws if it doesn't exist.- Returns:
- Returns the neighbor shape.
- Throws:
ExpectationNotMetException
- if the neighbor is missing.
-
getSelectorLabel
Gets the token that is used inSelector
expressions when referring to the relationship or an emptyOptional
if this relationship is not used in a selector.- Returns:
- Returns the optionally present selector token for this relationship.
-
getDirection
Gets the direction of the relationship.A
RelationshipDirection.DIRECTED
direction is formed from a shape that defines a reference to another shape (for example, when a resource defines operations or resources it contains).A
RelationshipDirection.INVERTED
relationship is a relationship from a shape to a shape that defines a relationship to it. The target of such a relationship doesn't define the relationship, but is the target of the relationship.- Returns:
- Returns the direction of the relationship.
-
toString
-
equals
-
hashCode
public int hashCode()
-