1 package de.fhdw.wtf.persistence.meta;
2
3
4
5
6 public class Specialization {
7
8
9
10
11 private final Type ancestor;
12
13
14
15 private final Type descendant;
16
17
18
19
20
21
22
23
24
25 public Specialization(final Type ancestor, final Type descendant) {
26 this.ancestor = ancestor;
27 this.descendant = descendant;
28 }
29
30
31
32
33 public Type getAncestor() {
34 return this.ancestor;
35 }
36
37
38
39
40 public Type getDescendant() {
41 return this.descendant;
42 }
43
44 @Override
45 public boolean equals(final java.lang.Object obj) {
46 if (obj instanceof Specialization) {
47 final Specialization objAsSpecialization = (Specialization) obj;
48 return objAsSpecialization.getAncestor().isTheSameAs(this.getAncestor())
49 && objAsSpecialization.getDescendant().isTheSameAs(this.getDescendant());
50 }
51 return false;
52 }
53
54
55
56
57 private static final int HASHCODE_PRIME_FACTOR_1 = 13;
58
59
60
61 private static final int HASHCODE_PRIME_FACTOR_2 = 27;
62
63
64
65 private static final int HASHCODE_PRIME_FACTOR_3 = 42;
66
67 @Override
68 public int hashCode() {
69 int code = HASHCODE_PRIME_FACTOR_3;
70
71 code += HASHCODE_PRIME_FACTOR_1 * this.getAncestor().hashCode();
72 code += HASHCODE_PRIME_FACTOR_2 * this.getDescendant().hashCode();
73
74 return code;
75 }
76
77 }