aboutsummaryrefslogtreecommitdiffstats
path: root/store/src/main/java/tools/refinery/data/model/ModelCursor.java
blob: e3537c7d2b43072d9e440d7f62c2b655036d21cb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package tools.refinery.data.model;

import java.util.Map;

import tools.refinery.data.map.Cursor;
import tools.refinery.data.model.representation.DataRepresentation;

public class ModelCursor {
	final Map<DataRepresentation<?, ?>,Cursor<?,?>> cursors;

	public ModelCursor(Map<DataRepresentation<?, ?>, Cursor<?, ?>> cursors) {
		super();
		this.cursors = cursors;
	}
	
	@SuppressWarnings("unchecked")
	public <K,V> Cursor<K,V> getCursor(DataRepresentation<K, V> representation) {
		Cursor<?, ?> cursor = cursors.get(representation);
		if(cursor != null) {
			return (Cursor<K, V>) cursor;
		} else {
			throw new IllegalArgumentException("ModelCursor does not contain cursor for representation "+representation);
		}
	}
}