Skip to content

Package: Specialization

Specialization

nameinstructionbranchcomplexitylinemethod
Specialization(Type, Type)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
equals(Object)
M: 2 C: 22
92%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 1 C: 3
75%
M: 0 C: 1
100%
getAncestor()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getDescendant()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
hashCode()
M: 20 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%

Coverage

1: package de.fhdw.wtf.persistence.meta;
2:
3: /**
4: * Represents the specialization-relationship between an ancestor and its descendant.
5: */
6: public class Specialization {
7:         
8:         /**
9:          * The ancestor of this specialization-relationship.
10:          */
11:         private final Type ancestor;
12:         /**
13:          * The descendant of this specialization-relationship.
14:          */
15:         private final Type descendant;
16:         
17:         /**
18:          * Instantiates a new specialization-object with ancestor and descendant.
19:          *
20:          * @param ancestor
21:          * the ancestor of this specialization-relationship.
22:          * @param descendant
23:          * the descendant of this specialization-relationship.
24:          */
25:         public Specialization(final Type ancestor, final Type descendant) {
26:                 this.ancestor = ancestor;
27:                 this.descendant = descendant;
28:         }
29:         
30:         /**
31:          * @return the ancestor of this specialization-relationship.
32:          */
33:         public Type getAncestor() {
34:                 return this.ancestor;
35:         }
36:         
37:         /**
38:          * @return the descendant of this specialization-relationship.
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:          * Constant 1 for calculating hashCode.
56:          */
57:         private static final int HASHCODE_PRIME_FACTOR_1 = 13;
58:         /**
59:          * Constant 2 for calculating hashCode.
60:          */
61:         private static final int HASHCODE_PRIME_FACTOR_2 = 27;
62:         /**
63:          * Constant 2 for calculating hashCode.
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: }