aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects
diff options
context:
space:
mode:
authorLibravatar Attila Ficsor <ficsorattila96@gmail.com>2023-08-08 14:33:34 +0200
committerLibravatar Attila Ficsor <ficsorattila96@gmail.com>2023-08-08 14:33:34 +0200
commit089613c3cc44ec3dcc88d2a515d8c66a0f32484f (patch)
treec05363ffa2ae6679822fe89597efc43206193309 /subprojects
parentRefactor search strategy to improve readability (diff)
parentMerge pull request #34 from OszkarSemerath/datastructure (diff)
downloadrefinery-089613c3cc44ec3dcc88d2a515d8c66a0f32484f.tar.gz
refinery-089613c3cc44ec3dcc88d2a515d8c66a0f32484f.tar.zst
refinery-089613c3cc44ec3dcc88d2a515d8c66a0f32484f.zip
Merge remote-tracking branch 'graphs4value/main' into design-space-exploration
Diffstat (limited to 'subprojects')
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/model/internal/ModelImpl.java8
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/model/internal/ModelVersion.java22
2 files changed, 14 insertions, 16 deletions
diff --git a/subprojects/store/src/main/java/tools/refinery/store/model/internal/ModelImpl.java b/subprojects/store/src/main/java/tools/refinery/store/model/internal/ModelImpl.java
index 92694af4..2b12d5a6 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/model/internal/ModelImpl.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/model/internal/ModelImpl.java
@@ -105,7 +105,7 @@ public class ModelImpl implements Model {
105 // Doing the commit on the interpretations 105 // Doing the commit on the interpretations
106 Version[] interpretationVersions = new Version[interpretations.size()]; 106 Version[] interpretationVersions = new Version[interpretations.size()];
107 int j = 0; 107 int j = 0;
108 for(var interpretationEntry : interpretations.entrySet()) { 108 for (var interpretationEntry : interpretations.entrySet()) {
109 interpretationVersions[j++] = interpretationEntry.getValue().commit(); 109 interpretationVersions[j++] = interpretationEntry.getValue().commit();
110 } 110 }
111 ModelVersion modelVersion = new ModelVersion(interpretationVersions); 111 ModelVersion modelVersion = new ModelVersion(interpretationVersions);
@@ -140,7 +140,7 @@ public class ModelImpl implements Model {
140 } 140 }
141 int j = 0; 141 int j = 0;
142 for (var interpretation : interpretations.values()) { 142 for (var interpretation : interpretations.values()) {
143 interpretation.restore(ModelVersion.getInternalVersion(version,j++)); 143 interpretation.restore(ModelVersion.getInternalVersion(version, j++));
144 } 144 }
145 145
146 setState(version); 146 setState(version);
@@ -187,8 +187,4 @@ public class ModelImpl implements Model {
187 public void removeListener(ModelListener listener) { 187 public void removeListener(ModelListener listener) {
188 listeners.remove(listener); 188 listeners.remove(listener);
189 } 189 }
190
191 public Map<? extends AnySymbol, ? extends Interpretation<?>> getInterpretations() {
192 return interpretations;
193 }
194} 190}
diff --git a/subprojects/store/src/main/java/tools/refinery/store/model/internal/ModelVersion.java b/subprojects/store/src/main/java/tools/refinery/store/model/internal/ModelVersion.java
index cf3b7fc6..f81386f1 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/model/internal/ModelVersion.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/model/internal/ModelVersion.java
@@ -9,25 +9,27 @@ import tools.refinery.store.map.Version;
9 9
10import java.util.Arrays; 10import java.util.Arrays;
11 11
12public record ModelVersion(Version[] mapVersions) implements Version{ 12public class ModelVersion implements Version {
13 final Version[] mapVersions;
14 final int hash;
15
16 public ModelVersion(Version[] mapVersions) {
17 this.mapVersions = mapVersions;
18 this.hash = Arrays.hashCode(mapVersions);
19 }
13 20
14 public static Version getInternalVersion(Version modelVersion, int interpretationIndex) { 21 public static Version getInternalVersion(Version modelVersion, int interpretationIndex) {
15 return ((ModelVersion)modelVersion).mapVersions()[interpretationIndex]; 22 return ((ModelVersion) modelVersion).mapVersions[interpretationIndex];
16 } 23 }
17 24
18 @Override 25 @Override
19 public int hashCode() { 26 public int hashCode() {
20 return Arrays.hashCode(mapVersions); 27 return hash;
21 } 28 }
22 29
23 @Override 30 @Override
24 public boolean equals(Object o) { 31 public boolean equals(Object obj) {
25 if (this == o) return true; 32 return super.equals(obj);
26 if (o == null || getClass() != o.getClass()) return false;
27
28 ModelVersion that = (ModelVersion) o;
29
30 return Arrays.equals(mapVersions, that.mapVersions);
31 } 33 }
32 34
33 @Override 35 @Override