From 354ff11cfa8bc2baf879a61ede8a3afebdeeabda Mon Sep 17 00:00:00 2001 From: OszkarSemerath Date: Sun, 5 Feb 2023 01:32:16 +0100 Subject: DiffCursor value comparison support for null values. in case null != default --- .../tools/refinery/store/map/internal/MapDiffCursor.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'subprojects/store/src/main/java/tools') diff --git a/subprojects/store/src/main/java/tools/refinery/store/map/internal/MapDiffCursor.java b/subprojects/store/src/main/java/tools/refinery/store/map/internal/MapDiffCursor.java index beaff13b..6c076ce5 100644 --- a/subprojects/store/src/main/java/tools/refinery/store/map/internal/MapDiffCursor.java +++ b/subprojects/store/src/main/java/tools/refinery/store/map/internal/MapDiffCursor.java @@ -5,6 +5,7 @@ import tools.refinery.store.map.ContinousHashProvider; import tools.refinery.store.map.Cursor; import tools.refinery.store.map.DiffCursor; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -121,7 +122,7 @@ public class MapDiffCursor implements DiffCursor, Cursor { this.fromValue = defaultValue; this.toValue = cursor2.value; } else { - throw new IllegalArgumentException("Inconsistent compare result for diffcursor"); + throw new IllegalArgumentException("Inconsistent compare result for diffCursor"); } } @@ -145,16 +146,17 @@ public class MapDiffCursor implements DiffCursor, Cursor { this.fromValue = defaultValue; this.toValue = cursor2.value; } - default -> throw new IllegalArgumentException("Inconsistent compare result for diffcursor"); + default -> throw new IllegalArgumentException("Inconsistent compare result for diffCursor"); } } + /** + * Checks if two states has the same values, i.e., there is no difference. + * @return whether two states has the same values + */ protected boolean sameValues() { - if (this.fromValue == null) { - return this.toValue == null; - } else { - return this.fromValue.equals(this.toValue); - } + if(cursor1.isTerminated() || cursor2.isTerminated()) return false; + else return Objects.equals(this.fromValue, this.toValue); } protected boolean moveOne() { -- cgit v1.2.3-70-g09d2