-
Notifications
You must be signed in to change notification settings - Fork 2
/
InstanceContext.java
43 lines (31 loc) · 1.22 KB
/
InstanceContext.java
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cz.cvut.kbss.jsonld.deserialization;
import java.lang.reflect.Field;
import java.util.Map;
abstract class InstanceContext<T> {
final T instance;
final Map<String, Object> knownInstances;
InstanceContext(T instance, Map<String, Object> knownInstances) {
this.instance = instance;
this.knownInstances = knownInstances;
}
T getInstance() {
return instance;
}
@SuppressWarnings("unchecked")
Class<T> getInstanceType() {
return (Class<T>) instance.getClass();
}
// These methods are intended for overriding, because the behaviour is supported only by some context implementations
Field getFieldForProperty(String property) {
throw new UnsupportedOperationException("Not supported by this type of instance context");
}
void setFieldValue(Field field, Object value) {
throw new UnsupportedOperationException("Not supported by this type of instance context");
}
void addItem(Object item) {
throw new UnsupportedOperationException("Not supported by this type of instance context");
}
Class<?> getItemType() {
throw new UnsupportedOperationException("Not supported by this type of instance context");
}
}