1
2
3
4
5
6
7 package org.asyrinx.joey.gen.model.rdb;
8
9 import org.apache.commons.lang.builder.EqualsBuilder;
10 import org.asyrinx.joey.gen.model.Element;
11
12 /***
13 * @author akima
14 */
15 public class ForeignKeyEntry extends Element {
16
17 /***
18 *
19 */
20 public ForeignKeyEntry() {
21 super();
22 }
23
24 /***
25 *
26 */
27 public ForeignKeyEntry(String local, String foreign) {
28 this(null, local, foreign);
29 }
30
31 /***
32 *
33 */
34 public ForeignKeyEntry(ForeignKey parent, String local, String foreign) {
35 super(parent);
36 this.local = local;
37 this.foreign = foreign;
38 }
39
40
41
42
43
44
45 public ForeignKey getParent() {
46 return (ForeignKey) super.getParentElement();
47 }
48
49 private String local = null;
50
51 private String foreign = null;
52
53 /***
54 * @return Returns the foreign.
55 */
56 public String getForeign() {
57 return foreign;
58 }
59
60 /***
61 * @param foreign
62 * The foreign to set.
63 */
64 public void setForeign(String foreign) {
65 this.foreign = foreign;
66 }
67
68 /***
69 * @return Returns the local.
70 */
71 public String getLocal() {
72 return local;
73 }
74
75 /***
76 * @param local
77 * The local to set.
78 */
79 public void setLocal(String local) {
80 this.local = local;
81 }
82
83 public Column getLocalColumn() {
84 if (getParent() == null)
85 return null;
86 final Table table = getParent().getLocal();
87 return table.getColumns().getColumn(getLocal());
88 }
89
90 public Column getForeignColumn() {
91 if (getParent() == null)
92 return null;
93 final Table table = getParent().getForeignTable();
94 return table.getColumns().getColumn(getForeign());
95 }
96
97
98
99
100
101
102 public boolean equals(Object obj) {
103 if (!super.equals(obj))
104 return false;
105 if (!(obj instanceof ForeignKeyEntry))
106 return false;
107 final ForeignKeyEntry other = (ForeignKeyEntry) obj;
108 return new EqualsBuilder()
109 .append(this.getLocal(), other.getLocal())
110 .append(this.getForeign(), other.getForeign())
111 .isEquals();
112 }
113 }