Skip to content

Package: MapLink

MapLink

nameinstructionbranchcomplexitylinemethod
MapLink(long, UserObject, Object, Object, MapAssociation)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
equals(Object)
M: 28 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getInstanceOf()
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%
getKey()
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: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
toString()
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: package de.fhdw.wtf.persistence.meta;
2:
3: import de.fhdw.wtf.persistence.exception.NotValidInputException;
4:
5: /**
6: * A class to represent a connection between three objects in the database. The UnidirectionalLink itself is an instance
7: * of an association3.
8: *
9: */
10: public class MapLink extends Link {
11:         
12:         /**
13:          * The hashmap-key object.
14:          */
15:         private final Object key;
16:         
17:         /**
18:          * Getter for the key of this UnidirectionalLink.
19:          *
20:          * @return Provides an Object, which is the key of this link.
21:          */
22:         public Object getKey() {
23:                 return this.key;
24:         }
25:         
26:         /**
27:          * The type of this link.
28:          */
29:         private final MapAssociation instanceOf;
30:         
31:         @Override
32:         public MapAssociation getInstanceOf() {
33:                 return this.instanceOf;
34:         }
35:         
36:         /**
37:          * Constructor for a new UnidirectionalLink, it should only be called by the Object Facade or Junit Test to
38:          * guarantee a valid consistency with the database.
39:          *
40:          * @param id
41:          * The Id of the UnidirectionalLink, determined by the database.
42:          * @param owner
43:          * The owner of the this UnidirectionalLink. A User Object.
44:          * @param target
45:          * The target of this link. An Object.
46:          * @param key
47:          * The hashmap-key of this link. An Object.
48:          * @param instanceOf
49:          * The type of this link.
50:          * @throws NotValidInputException
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: }