1 package de.fhdw.wtf.context.model.collections;
2
3 import de.fhdw.wtf.context.model.Anything;
4 import de.fhdw.wtf.persistence.meta.UserObject;
5
6
7
8
9
10
11
12
13
14
15 public class PersistentMap<K extends Anything, V extends Anything> extends MutableMap<K, V> {
16
17
18
19
20 private transient PersistentMapWithKeyValueLinks<Anything, Anything> links;
21
22
23
24 public static final String linksAssociationName = "links";
25
26
27
28
29 public PersistentMap() {
30 this.initLinks();
31 }
32
33
34
35
36
37
38
39 public PersistentMap(final UserObject userObject) {
40 super(userObject);
41 this.initLinks();
42 }
43
44
45
46
47 private void initLinks() {
48 final String assocName = PersistentMap.class.getName() + "." + linksAssociationName;
49 this.links = new PersistentMapWithKeyValueLinks<>(this.getObject(), assocName);
50 }
51
52 @Override
53 public void put(final K key, final V value) {
54 this.links.put(key, value);
55 }
56
57 @SuppressWarnings("unchecked")
58 @Override
59 public V get(final K key) {
60 return (V) this.links.get(key);
61 }
62
63 @SuppressWarnings("unchecked")
64 @Override
65 public V remove(final K key) {
66 return (V) this.links.remove(key);
67 }
68 }