1 package de.fhdw.wtf.persistence.meta;
2
3 import de.fhdw.wtf.persistence.exception.NotValidInputException;
4
5
6
7
8
9
10 public class MapLink extends Link {
11
12
13
14
15 private final Object key;
16
17
18
19
20
21
22 public Object getKey() {
23 return this.key;
24 }
25
26
27
28
29 private final MapAssociation instanceOf;
30
31 @Override
32 public MapAssociation getInstanceOf() {
33 return this.instanceOf;
34 }
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 public MapLink(final long id,
53 final UserObject owner,
54 final Object target,
55 final Object key,
56 final MapAssociation instanceOf) throws NotValidInputException {
57 super(id, owner, target);
58 this.key = key;
59 this.instanceOf = instanceOf;
60
61 }
62
63 @Override
64 public String toString() {
65 return "MapLink<" + this.getId() + ">";
66 }
67
68 @Override
69 public boolean equals(final java.lang.Object other) {
70 if (!(other instanceof MapLink)) {
71 return false;
72 }
73
74 final MapLink link = (MapLink) other;
75 return super.equals(link) && this.getInstanceOf().equals(link.getInstanceOf())
76 && this.getKey().equals(link.getKey());
77 }
78
79 @Override
80 public int hashCode() {
81 return super.hashCode() ^ this.instanceOf.hashCode() ^ this.key.hashCode();
82 }
83 }