Class DirectionUtils

    • 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 is Direction.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 to Direction.BOTH, then the method always returns true.
        direction - to match. If Direction.BOTH, then the method always returns true.
        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 - one
        direction2 - two
        Returns:
        true iff at least one of the directions is Direction.BOTH or they are equal.
      • reverse

        public static Direction reverse​(Direction direction)
        Reverse direction.
        Parameters:
        direction - to reverse.
        Returns:
        reversed direction.