1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package eu.ehri.project.models.base;
21
22 import com.tinkerpop.blueprints.Vertex;
23 import com.tinkerpop.frames.Property;
24 import com.tinkerpop.frames.VertexFrame;
25 import com.tinkerpop.frames.modules.javahandler.JavaHandler;
26 import com.tinkerpop.frames.modules.javahandler.JavaHandlerContext;
27 import eu.ehri.project.models.annotations.EntityType;
28 import eu.ehri.project.models.annotations.Mandatory;
29
30 import java.util.Set;
31
32
33
34
35 public interface Entity extends VertexFrame {
36
37
38
39
40
41
42
43
44 @JavaHandler
45 <T extends Entity> T as(Class<T> cls);
46
47
48
49
50
51
52 @Mandatory
53 @Property(EntityType.ID_KEY)
54 String getId();
55
56
57
58
59
60
61 @Mandatory
62 @Property(EntityType.TYPE_KEY)
63 String getType();
64
65
66
67
68
69
70
71 @JavaHandler
72 <T> T getProperty(String key);
73
74 @JavaHandler
75 <T> T getProperty(Enum<?> key);
76
77
78
79
80
81
82
83 @JavaHandler
84 Set<String> getPropertyKeys();
85
86 abstract class Impl implements JavaHandlerContext<Vertex>, Accessible {
87
88 @Override
89 public <T extends Entity> T as(Class<T> cls) {
90 return frame(it(), cls);
91 }
92
93 @Override
94 public <T> T getProperty(String key) {
95 return it().getProperty(key);
96 }
97
98 @Override
99 public <T> T getProperty(Enum<?> key) {
100 return it().getProperty(key.name());
101 }
102
103 @Override
104 public Set<String> getPropertyKeys() {
105 return it().getPropertyKeys();
106 }
107 }
108 }