1 package de.fhdw.wtf.persistence.meta;
2
3
4
5
6
7
8 public abstract class Link extends InstanceItem {
9
10
11
12
13 private final long id;
14
15
16
17
18 private final UserObject owner;
19
20
21
22
23 private final Object target;
24
25
26
27
28
29
30 public abstract Association getInstanceOf();
31
32
33
34
35
36
37 public UserObject getOwner() {
38 return this.owner;
39 }
40
41
42
43
44
45
46 public Object getTarget() {
47 return this.target;
48 }
49
50
51
52
53
54
55
56
57
58
59
60
61 public Link(final long id, final UserObject owner, final Object target) {
62 super();
63 this.id = id;
64 this.owner = owner;
65 this.target = target;
66 }
67
68 @Override
69 public long getId() {
70 return this.id;
71 }
72
73 @Override
74 public boolean equals(final java.lang.Object obj) {
75 if (!(obj instanceof Link)) {
76 return false;
77 }
78
79 final Link link = (Link) obj;
80 return this.getOwner().equals(link.getOwner()) && this.getTarget().equals(link.getTarget());
81 }
82
83 @Override
84 public int hashCode() {
85 return this.owner.hashCode() ^ this.target.hashCode();
86 }
87
88 @Override
89 public String toString() {
90 return "UnidirectionalLink<" + this.getId() + ">";
91 }
92
93 @Override
94 public boolean isTheSameAs(final java.lang.Object other) {
95 if (!(other instanceof Link)) {
96 return false;
97 }
98
99 return this.getId() == ((Link) other).getId();
100 }
101
102 }