Package com.graphaware.common.util
Class RelationshipUtils
- java.lang.Object
-
- com.graphaware.common.util.RelationshipUtils
-
public final class RelationshipUtils extends Object
Utility methods for dealing withRelationship
s.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Relationship
createRelationshipIfNotExists(EvaluationContext context, Node node1, Node node2, RelationshipType type, Direction direction)
Create a relationship if one doesn't already exist.static void
deleteRelationshipIfExists(EvaluationContext context, Node node1, Node node2, RelationshipType type, Direction direction)
Delete a relationship if one exists.static Relationship
getSingleRelationship(EvaluationContext context, Node node1, Node node2, RelationshipType type, Direction direction)
Get a single relationship between two nodes.static Relationship
getSingleRelationshipOrNull(EvaluationContext context, Node node1, Node node2, RelationshipType type, Direction direction)
Get a single relationship between two nodes.static boolean
relationshipExists(EvaluationContext context, Node node1, Node node2, RelationshipType type, Direction direction)
Check that a relationship exists between two nodes.static boolean
relationshipNotExists(EvaluationContext context, Node node1, Node node2, RelationshipType type, Direction direction)
Check that a relationship does not exist between two nodes.
-
-
-
Method Detail
-
getSingleRelationship
public static Relationship getSingleRelationship(EvaluationContext context, Node node1, Node node2, RelationshipType type, Direction direction)
Get a single relationship between two nodes.- Parameters:
context
- evaluation context of the transaction.node1
- first node.node2
- second node.type
- relationship type.direction
- relationship direction from first node's point of view (can be BOTH).- Returns:
- a single relationship. If there is more than one relationship, one (unspecified which one) will be returned.
- Throws:
NotFoundException
- if there is no such relationship.
-
getSingleRelationshipOrNull
public static Relationship getSingleRelationshipOrNull(EvaluationContext context, Node node1, Node node2, RelationshipType type, Direction direction)
Get a single relationship between two nodes.- Parameters:
context
- evaluation context of the transaction.node1
- first node.node2
- second node.type
- relationship type.direction
- relationship direction from first node's point of view (can be BOTH).- Returns:
- a single relationship, null if there is no such relationship between the nodes. If there is more than one relationship, one (unspecified which one) will be returned.
-
relationshipNotExists
public static boolean relationshipNotExists(EvaluationContext context, Node node1, Node node2, RelationshipType type, Direction direction)
Check that a relationship does not exist between two nodes.- Parameters:
context
- evaluation context of the transaction.node1
- first node.node2
- second node.type
- relationship type.direction
- relationship direction from first node's point of view (can be BOTH).- Returns:
- true iff the specified relationship does not exist.
-
relationshipExists
public static boolean relationshipExists(EvaluationContext context, Node node1, Node node2, RelationshipType type, Direction direction)
Check that a relationship exists between two nodes.- Parameters:
context
- evaluation context of the transaction.node1
- first node.node2
- second node.type
- relationship type.direction
- relationship direction from first node's point of view (can be BOTH).- Returns:
- true iff at least one relationship with the above spec exists.
-
deleteRelationshipIfExists
public static void deleteRelationshipIfExists(EvaluationContext context, Node node1, Node node2, RelationshipType type, Direction direction)
Delete a relationship if one exists. Do nothing if the specified relationship does not exist.- Parameters:
context
- evaluation context of the transaction.node1
- first node.node2
- second node.type
- relationship type.direction
- relationship direction from first node's point of view (can be BOTH).
-
createRelationshipIfNotExists
public static Relationship createRelationshipIfNotExists(EvaluationContext context, Node node1, Node node2, RelationshipType type, Direction direction)
Create a relationship if one doesn't already exist. Do nothing if one does exist.- Parameters:
context
- evaluation context of the transaction.node1
- first node.node2
- second node.type
- relationship type.direction
- relationship direction from first node's point of view (can be BOTH).- Returns:
- the new or the existing relationship.
-
-