1 /***
2 *
3 */
4 package org.kite9.diagram.builders;
5
6 import org.kite9.framework.alias.AliasEnabled;
7
8 /***
9 * Named Arrows are bound to their subjects, so a relationship and a subject form a binding which
10 * is represented by a single arrow
11 *
12 * @author robmoffat
13 *
14 */
15 class SubjectBinding<X> implements AliasEnabled {
16
17 public SubjectBinding(X subject, Relationship r) {
18 super();
19 this.cl = subject;
20 this.r = r;
21 }
22
23 X cl;
24
25 Relationship r;
26
27
28 public X getSubject() {
29 return cl;
30 }
31
32 public Object getObjectForAlias() {
33 return r;
34 }
35 public Relationship getRelationship() {
36 return r;
37 }
38
39 @Override
40 public int hashCode() {
41 final int prime = 31;
42 int result = 1;
43 result = prime * result + ((cl == null) ? 0 : cl.hashCode());
44 result = prime * result + ((r == null) ? 0 : r.hashCode());
45 return result;
46 }
47
48 @Override
49 public boolean equals(Object obj) {
50 if (this == obj)
51 return true;
52 if (obj == null)
53 return false;
54 if (getClass() != obj.getClass())
55 return false;
56
57 SubjectBinding<?> other = (SubjectBinding<?>) obj;
58 if (cl == null) {
59 if (other.cl != null)
60 return false;
61 } else if (!cl.equals(other.cl))
62 return false;
63 if (r == null) {
64 if (other.r != null)
65 return false;
66 } else if (!r.equals(other.r))
67 return false;
68 return true;
69 }
70
71
72 }