Skip to content

Method: getInstanceOf()

1: package de.fhdw.wtf.persistence.meta;
2:
3: /**
4: * object of a point-to-point association.
5: */
6: public class UnidirectionalLink extends Link {
7:         
8:         /**
9:          * The type of this link.
10:          */
11:         private final UnidirectionalAssociation instanceOf;
12:         
13:         @Override
14:         public UnidirectionalAssociation getInstanceOf() {
15:                 return this.instanceOf;
16:         }
17:         
18:         /**
19:          * creates a unidirectional link between two objects.
20:          *
21:          * @param id
22:          * the id of the link
23:          * @param owner
24:          * the owner of the link
25:          * @param target
26:          * the target of the link
27:          * @param instanceOf
28:          * the unidirectional association of the link
29:          */
30:         public UnidirectionalLink(final long id,
31:                         final UserObject owner,
32:                         final Object target,
33:                         final UnidirectionalAssociation instanceOf) {
34:                 super(id, owner, target);
35:                 this.instanceOf = instanceOf;
36:         }
37:         
38:         @Override
39:         public boolean equals(final java.lang.Object other) {
40:                 if (!(other instanceof UnidirectionalLink)) {
41:                         return false;
42:                 }
43:                 
44:                 final UnidirectionalLink unidirectionalLink = (UnidirectionalLink) other;
45:                 return super.equals(unidirectionalLink) && this.getInstanceOf().equals(unidirectionalLink.getInstanceOf());
46:         }
47:         
48:         @Override
49:         public int hashCode() {
50:                 return super.hashCode() ^ this.instanceOf.hashCode();
51:         }
52: }