diff options
author | 2021-08-10 01:11:22 +0200 | |
---|---|---|
committer | 2021-08-10 01:11:22 +0200 | |
commit | c4d066254f0dd0d795b01db7129565c75056c4ab (patch) | |
tree | 2dca1d37bd3e1024ecdea6bfa33877ff6e993ac9 | |
parent | Initial model version (diff) | |
download | refinery-c4d066254f0dd0d795b01db7129565c75056c4ab.tar.gz refinery-c4d066254f0dd0d795b01db7129565c75056c4ab.tar.zst refinery-c4d066254f0dd0d795b01db7129565c75056c4ab.zip |
Simple collective cursors for models
-rw-r--r-- | model-data/src/main/java/org/eclipse/viatra/solver/data/model/ModelCursor.java | 25 | ||||
-rw-r--r-- | model-data/src/main/java/org/eclipse/viatra/solver/data/model/ModelDiffCursor.java | 26 |
2 files changed, 51 insertions, 0 deletions
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/ModelCursor.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/ModelCursor.java new file mode 100644 index 00000000..3157c9f0 --- /dev/null +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/ModelCursor.java | |||
@@ -0,0 +1,25 @@ | |||
1 | package org.eclipse.viatra.solver.data.model; | ||
2 | |||
3 | import java.util.Map; | ||
4 | |||
5 | import org.eclipse.viatra.solver.data.map.Cursor; | ||
6 | import org.eclipse.viatra.solver.data.model.representation.DataRepresentation; | ||
7 | |||
8 | public class ModelCursor { | ||
9 | final Map<DataRepresentation<?, ?>,Cursor<?,?>> cursors; | ||
10 | |||
11 | public ModelCursor(Map<DataRepresentation<?, ?>, Cursor<?, ?>> cursors) { | ||
12 | super(); | ||
13 | this.cursors = cursors; | ||
14 | } | ||
15 | |||
16 | @SuppressWarnings("unchecked") | ||
17 | public <K,V> Cursor<K,V> getCursor(DataRepresentation<K, V> representation) { | ||
18 | Cursor<?, ?> cursor = cursors.get(representation); | ||
19 | if(cursor != null) { | ||
20 | return (Cursor<K, V>) cursor; | ||
21 | } else { | ||
22 | throw new IllegalArgumentException("ModelCursor does not contain cursor for representation "+representation); | ||
23 | } | ||
24 | } | ||
25 | } | ||
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/ModelDiffCursor.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/ModelDiffCursor.java new file mode 100644 index 00000000..d3551e47 --- /dev/null +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/ModelDiffCursor.java | |||
@@ -0,0 +1,26 @@ | |||
1 | package org.eclipse.viatra.solver.data.model; | ||
2 | |||
3 | import java.util.Map; | ||
4 | |||
5 | import org.eclipse.viatra.solver.data.map.Cursor; | ||
6 | import org.eclipse.viatra.solver.data.map.DiffCursor; | ||
7 | import org.eclipse.viatra.solver.data.model.representation.DataRepresentation; | ||
8 | |||
9 | public class ModelDiffCursor { | ||
10 | final Map<DataRepresentation<?, ?>,DiffCursor<?,?>> diffcursors; | ||
11 | |||
12 | public ModelDiffCursor(Map<DataRepresentation<?, ?>, DiffCursor<?, ?>> diffcursors) { | ||
13 | super(); | ||
14 | this.diffcursors = diffcursors; | ||
15 | } | ||
16 | |||
17 | @SuppressWarnings("unchecked") | ||
18 | public <K,V> DiffCursor<K,V> getCursor(DataRepresentation<K, V> representation) { | ||
19 | Cursor<?, ?> cursor = diffcursors.get(representation); | ||
20 | if(cursor != null) { | ||
21 | return (DiffCursor<K, V>) cursor; | ||
22 | } else { | ||
23 | throw new IllegalArgumentException("ModelCursor does not contain cursor for representation "+representation); | ||
24 | } | ||
25 | } | ||
26 | } | ||