aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store/src
diff options
context:
space:
mode:
authorLibravatar OszkarSemerath <semerath@mit.bme.hu>2023-02-05 01:32:16 +0100
committerLibravatar OszkarSemerath <semerath@mit.bme.hu>2023-02-05 01:32:16 +0100
commit354ff11cfa8bc2baf879a61ede8a3afebdeeabda (patch)
tree24818d6c71c9eae2b15596eb59859f3c2435df65 /subprojects/store/src
parentCode quality improvements in cursors (diff)
downloadrefinery-354ff11cfa8bc2baf879a61ede8a3afebdeeabda.tar.gz
refinery-354ff11cfa8bc2baf879a61ede8a3afebdeeabda.tar.zst
refinery-354ff11cfa8bc2baf879a61ede8a3afebdeeabda.zip
DiffCursor value comparison support for null values.
in case null != default
Diffstat (limited to 'subprojects/store/src')
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/map/internal/MapDiffCursor.java16
1 files changed, 9 insertions, 7 deletions
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;
5import tools.refinery.store.map.Cursor; 5import tools.refinery.store.map.Cursor;
6import tools.refinery.store.map.DiffCursor; 6import tools.refinery.store.map.DiffCursor;
7 7
8import java.util.Objects;
8import java.util.Set; 9import java.util.Set;
9import java.util.stream.Collectors; 10import java.util.stream.Collectors;
10import java.util.stream.Stream; 11import java.util.stream.Stream;
@@ -121,7 +122,7 @@ public class MapDiffCursor<K, V> implements DiffCursor<K, V>, Cursor<K, V> {
121 this.fromValue = defaultValue; 122 this.fromValue = defaultValue;
122 this.toValue = cursor2.value; 123 this.toValue = cursor2.value;
123 } else { 124 } else {
124 throw new IllegalArgumentException("Inconsistent compare result for diffcursor"); 125 throw new IllegalArgumentException("Inconsistent compare result for diffCursor");
125 } 126 }
126 } 127 }
127 128
@@ -145,16 +146,17 @@ public class MapDiffCursor<K, V> implements DiffCursor<K, V>, Cursor<K, V> {
145 this.fromValue = defaultValue; 146 this.fromValue = defaultValue;
146 this.toValue = cursor2.value; 147 this.toValue = cursor2.value;
147 } 148 }
148 default -> throw new IllegalArgumentException("Inconsistent compare result for diffcursor"); 149 default -> throw new IllegalArgumentException("Inconsistent compare result for diffCursor");
149 } 150 }
150 } 151 }
151 152
153 /**
154 * Checks if two states has the same values, i.e., there is no difference.
155 * @return whether two states has the same values
156 */
152 protected boolean sameValues() { 157 protected boolean sameValues() {
153 if (this.fromValue == null) { 158 if(cursor1.isTerminated() || cursor2.isTerminated()) return false;
154 return this.toValue == null; 159 else return Objects.equals(this.fromValue, this.toValue);
155 } else {
156 return this.fromValue.equals(this.toValue);
157 }
158 } 160 }
159 161
160 protected boolean moveOne() { 162 protected boolean moveOne() {