View Javadoc

1   /***
2    * 
3    */
4   package org.kite9.diagram.builders;
5   
6   import org.kite9.framework.alias.AliasEnabled;
7   
8   /***
9    * A Tie is used to hold a piece of relationship information.  E.g. John eats fish.  Where John is 
10   * the subject, eats is the relationship and fish is the object.
11   * 
12   * @author robmoffat
13   *
14   */
15  public class Tie<X, Y> implements AliasEnabled {
16  
17      public Tie(X subject, Relationship r, Y object) {
18          super();
19          this.cl = subject;
20          this.name = object;
21          this.r = r;
22      }
23      X cl;
24      Y name;
25      Relationship r;
26      
27      @Override
28      public int hashCode() {
29  	final int prime = 31;
30  	int result = 1;
31  	result = prime * result + ((cl == null) ? 0 : cl.hashCode());
32  	result = prime * result + ((name == null) ? 0 : name.hashCode());
33  	return result;
34      }
35      @Override
36      public boolean equals(Object obj) {
37  	if (this == obj)
38  	    return true;
39  	if (obj == null)
40  	    return false;
41  	if (getClass() != obj.getClass())
42  	    return false;
43  	Tie<?,?> other = (Tie<?,?>) obj;
44  	if (cl == null) {
45  	    if (other.cl != null)
46  		return false;
47  	} else if (!cl.equals(other.cl))
48  	    return false;
49  	if (name == null) {
50  	    if (other.name != null)
51  		return false;
52  	} else if (!name.equals(other.name))
53  	    return false;
54  	return true;
55      }
56      public X getSubject() {
57          return cl;
58      }
59      public Y getObject() {
60          return name;
61      }
62      public Object getObjectForAlias() {
63  	return name;
64      }
65      public Relationship getRelationship() {
66  	return r;
67      }
68      
69      
70  }