diff options
author | 2021-08-11 03:11:13 +0200 | |
---|---|---|
committer | 2021-08-11 03:11:13 +0200 | |
commit | 106b787031a36d607ac560f1ef1bb0f4b776109b (patch) | |
tree | 89faac1573d7d29dcf4848020d2de48c95b00cd0 /model-data | |
parent | Potential concurrent modification exception in multithread env resolved (diff) | |
download | refinery-106b787031a36d607ac560f1ef1bb0f4b776109b.tar.gz refinery-106b787031a36d607ac560f1ef1bb0f4b776109b.tar.zst refinery-106b787031a36d607ac560f1ef1bb0f4b776109b.zip |
Missed the ugly solution from map.put
Diffstat (limited to 'model-data')
-rw-r--r-- | model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/OldValueBox.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/OldValueBox.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/OldValueBox.java new file mode 100644 index 00000000..23502857 --- /dev/null +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/OldValueBox.java | |||
@@ -0,0 +1,19 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.internal; | ||
2 | |||
3 | public class OldValueBox<V>{ | ||
4 | V oldValue; | ||
5 | boolean isSet = false; | ||
6 | |||
7 | public V getOldValue() { | ||
8 | if(!isSet) throw new IllegalStateException(); | ||
9 | isSet = false; | ||
10 | return oldValue; | ||
11 | } | ||
12 | |||
13 | public void setOldValue(V ouldValue) { | ||
14 | if(isSet) throw new IllegalStateException(); | ||
15 | this.oldValue = ouldValue; | ||
16 | isSet = true; | ||
17 | } | ||
18 | |||
19 | } | ||