1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package pl.edu.agh.cast.model.mapper.internal;
19
20 import java.util.HashMap;
21 import java.util.HashSet;
22 import java.util.LinkedList;
23 import java.util.Map;
24 import java.util.Set;
25
26 import org.apache.log4j.Logger;
27
28 import pl.edu.agh.cast.model.base.BasePlugin;
29 import pl.edu.agh.cast.model.mapper.Mappable;
30 import pl.edu.agh.cast.model.mapper.Node;
31 import pl.edu.agh.cast.model.mapper.Saver;
32 import pl.edu.agh.cast.model.mapper.annotation.Mapping;
33
34
35
36
37
38
39 public abstract class AbstractSaver implements Saver {
40
41
42
43
44 protected static Logger log = BasePlugin.getLogger();
45
46
47
48
49 protected Mappable primaryObject;
50
51
52
53
54 protected boolean force;
55
56 private Map<Class<Mappable>, Mapping> classMap = new HashMap<Class<Mappable>, Mapping>();
57
58
59
60
61 protected Set<Mappable> visited = new HashSet<Mappable>();
62
63
64
65
66 protected Set<Mappable> stored = new HashSet<Mappable>();
67
68
69
70
71 protected LinkedList<Mappable> queue = new LinkedList<Mappable>();
72
73
74
75
76 protected Map<Long, Node> nodes = new HashMap<Long, Node>();
77
78
79
80
81
82
83
84
85 public AbstractSaver(Mappable object, boolean force2) {
86 primaryObject = object;
87 force = force2;
88 }
89
90 protected Mapping getMapping(Class<Mappable> klass) {
91 if (!classMap.containsKey(klass)) {
92 classMap.put(klass, klass.getAnnotation(Mapping.class));
93 }
94 return classMap.get(klass);
95 }
96
97 }