Class NodePair

java.lang.Object
org.openstreetmap.josm.data.osm.NodePair

public class NodePair extends Object
A directed pair of nodes (a,b != b,a).
Since:
12463 (extracted from CombineWayAction)
  • Field Details

    • a

      private final Node a
    • b

      private final Node b
  • Constructor Details

    • NodePair

      public NodePair(Node a, Node b)
      Constructs a new NodePair.
      Parameters:
      a - The first node
      b - The second node
    • NodePair

      public NodePair(Pair<Node,Node> pair)
      Constructs a new NodePair.
      Parameters:
      pair - An existing Pair of nodes
  • Method Details

    • getA

      public Node getA()
      Replies the first node.
      Returns:
      The first node
    • getB

      public Node getB()
      Replies the second node
      Returns:
      The second node
    • isSuccessorOf

      public boolean isSuccessorOf(NodePair other)
      Determines if this pair is successor of another one (other.b == this.a)
      Parameters:
      other - other pair
      Returns:
      true if other.b == this.a
    • isPredecessorOf

      public boolean isPredecessorOf(NodePair other)
      Determines if this pair is predecessor of another one (this.b == other.a)
      Parameters:
      other - other pair
      Returns:
      true if this.b == other.a
    • swap

      public NodePair swap()
      Returns the inversed pair.
      Returns:
      swapped copy
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • contains

      public boolean contains(Node n)
      Determines if this pair contains the given node.
      Parameters:
      n - The node to look for
      Returns:
      true if n is in the pair, false otherwise
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object