Skip to content

Commit ed7ff62

Browse files
committed
feat: Label::observablyEqual
1 parent 207aa53 commit ed7ff62

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • src/main/java/org/variantsync/diffdetective/variation

src/main/java/org/variantsync/diffdetective/variation/Label.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,18 @@ default Label withTimeDependentStateFrom(Label other, Time time) {
4848
* Creates a deep copy of this label.
4949
*/
5050
Label clone();
51+
52+
/**
53+
* Tests whether two labels are observably equal.
54+
* Observably equal means that the two labels
55+
* cannot be distinguished by using methods from this interface.
56+
* The given labels might indeed be of different classes or might
57+
* be considered unequal regarding {@link Object#equals(Object)}.
58+
*/
59+
static boolean observablyEqual(Label a, Label b) {
60+
if (a == null) return false;
61+
if (a == b) return true;
62+
return a.getLines().equals(b.getLines())
63+
&& a.getTrailingLines().equals(b.getTrailingLines());
64+
}
5165
}

0 commit comments

Comments
 (0)