Package com.graphaware.common.util
Class DirectionUtils
- java.lang.Object
-
- com.graphaware.common.util.DirectionUtils
-
public final class DirectionUtils extends Object
Utility class for static methods related toRelationship
Direction
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
matches(Direction direction1, Direction direction2)
Do the two directions match?static boolean
matches(Relationship relationship, Node pointOfView, Direction direction)
Does the given relationship match the given direction from the given node's point of view? Directions match if either they are the same, or at least one of them isDirection.BOTH
.static Direction
resolveDirection(AttachedRelationshipExpressions<?> relationship, AttachedNodeExpressions pointOfView, Direction defaultDirection)
Resolve the direction of a relationship from a node's point of view.static Direction
resolveDirection(Relationship relationship, Node pointOfView)
Resolve the direction of a relationship from a node's point of view.static Direction
resolveDirection(Relationship relationship, Node pointOfView, Direction defaultDirection)
Resolve the direction of a relationship from a node's point of view.static Direction
reverse(Direction direction)
Reverse direction.
-
-
-
Method Detail
-
resolveDirection
public static Direction resolveDirection(Relationship relationship, Node pointOfView)
Resolve the direction of a relationship from a node's point of view. If the start and end nodes of the relationship are the same node,Direction.BOTH
will be returned.- Parameters:
relationship
- to resolve direction for.pointOfView
- direction will be from this node's point of view.- Returns:
- direction of the relationship from the given node's point of view.
-
resolveDirection
public static Direction resolveDirection(Relationship relationship, Node pointOfView, Direction defaultDirection)
Resolve the direction of a relationship from a node's point of view.- Parameters:
relationship
- to resolve direction for.pointOfView
- direction will be from this node's point of view.defaultDirection
- value returned in case the relationship is a "self-relationships", i.e. the start and end nodes are the same.- Returns:
- direction of the relationship from the given node's point of view.
-
resolveDirection
public static Direction resolveDirection(AttachedRelationshipExpressions<?> relationship, AttachedNodeExpressions pointOfView, Direction defaultDirection)
Resolve the direction of a relationship from a node's point of view.- Parameters:
relationship
- to resolve direction for.pointOfView
- direction will be from this node's point of view.defaultDirection
- value returned in case the relationship is a "self-relationships", i.e. the start and end nodes are the same.- Returns:
- direction of the relationship from the given node's point of view.
-
matches
public static boolean matches(Relationship relationship, Node pointOfView, Direction direction)
Does the given relationship match the given direction from the given node's point of view? Directions match if either they are the same, or at least one of them isDirection.BOTH
.- Parameters:
relationship
- for which to check direction match.pointOfView
- direction of the above relationship will be resolved from this node's point of view. If it is resolved toDirection.BOTH
, then the method always returnstrue
.direction
- to match. IfDirection.BOTH
, then the method always returnstrue
.- Returns:
- true iff the relationship matches the direction from the given node's point of view.
-
matches
public static boolean matches(Direction direction1, Direction direction2)
Do the two directions match?- Parameters:
direction1
- onedirection2
- two- Returns:
- true iff at least one of the directions is
Direction.BOTH
or they are equal.
-
-