public final class Relationship
extends java.lang.Object
A relationship is a connection between two shapes. See
RelationshipType
for documentation on the possible
types of relationships.
Modifier and Type | Method and Description |
---|---|
static 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 |
equals(java.lang.Object other) |
Shape |
expectNeighborShape()
Gets the neighbor shape or throws if it doesn't exist.
|
RelationshipDirection |
getDirection()
Gets the direction of the relationship.
|
java.util.Optional<Shape> |
getNeighborShape()
Gets the optional neighbor shape; the neighbor shape may be empty
when the neighbor shape id was not in the model.
|
ShapeId |
getNeighborShapeId()
Gets the shape id of the neighbor shape.
|
RelationshipType |
getRelationshipType()
Gets the relationship type.
|
java.util.Optional<java.lang.String> |
getSelectorLabel()
Gets the token that is used in
Selector expressions when
referring to the relationship or an empty Optional if this
relationship is not used in a selector. |
Shape |
getShape()
Gets the starting shape in the relationship.
|
int |
hashCode() |
java.lang.String |
toString() |
public static Relationship create(Shape shape, RelationshipType relationshipType, Shape neighborShape)
shape
- The shape the relationship originates from.relationshipType
- The relationshipType of relationship.neighborShape
- The shape the relationship targets.public static Relationship createInvalid(Shape shape, RelationshipType relationshipType, ShapeId neighborShapeId)
shape
- The shape the relationship originates from.relationshipType
- The relationshipType of relationship.neighborShapeId
- The shape the relationship targets.public Shape getShape()
public RelationshipType getRelationshipType()
public ShapeId getNeighborShapeId()
public java.util.Optional<Shape> getNeighborShape()
public Shape expectNeighborShape()
ExpectationNotMetException
- if the neighbor is missing.public java.util.Optional<java.lang.String> getSelectorLabel()
Selector
expressions when
referring to the relationship or an empty Optional
if this
relationship is not used in a selector.public RelationshipDirection getDirection()
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.
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