|
15 | 15 | */
|
16 | 16 | package org.springframework.data.relational.core.sql;
|
17 | 17 |
|
| 18 | +import java.util.Objects; |
| 19 | + |
18 | 20 | import org.springframework.util.Assert;
|
19 | 21 |
|
20 | 22 | /**
|
21 |
| - * Represents a table reference within a SQL statement. Typically used to denote {@code FROM} or {@code JOIN} or to |
| 23 | + * Represents a table reference within a SQL statement. Typically, used to denote {@code FROM} or {@code JOIN} or to |
22 | 24 | * prefix a {@link Column}.
|
23 | 25 | * <p/>
|
24 | 26 | * Renders to: {@code <name>} or {@code <name> AS <name>}.
|
25 | 27 | *
|
26 | 28 | * @author Mark Paluch
|
| 29 | + * @author Jens Schauder |
27 | 30 | * @since 1.1
|
28 | 31 | */
|
29 | 32 | public class Table extends AbstractSegment implements TableLike {
|
@@ -107,7 +110,6 @@ public Table as(SqlIdentifier alias) {
|
107 | 110 | return new AliasedTable(name, alias);
|
108 | 111 | }
|
109 | 112 |
|
110 |
| - |
111 | 113 | /*
|
112 | 114 | * (non-Javadoc)
|
113 | 115 | * @see org.springframework.data.relational.core.sql.Named#getName()
|
@@ -135,6 +137,26 @@ public String toString() {
|
135 | 137 | return name.toString();
|
136 | 138 | }
|
137 | 139 |
|
| 140 | + @Override |
| 141 | + public boolean equals(Object o) { |
| 142 | + if (this == o) { |
| 143 | + return true; |
| 144 | + } |
| 145 | + if (o == null || getClass() != o.getClass()) { |
| 146 | + return false; |
| 147 | + } |
| 148 | + if (!super.equals(o)) { |
| 149 | + return false; |
| 150 | + } |
| 151 | + Table table = (Table) o; |
| 152 | + return name.equals(table.name); |
| 153 | + } |
| 154 | + |
| 155 | + @Override |
| 156 | + public int hashCode() { |
| 157 | + return Objects.hash(super.hashCode(), name); |
| 158 | + } |
| 159 | + |
138 | 160 | /**
|
139 | 161 | * {@link Aliased} {@link Table} implementation.
|
140 | 162 | */
|
@@ -184,5 +206,26 @@ public SqlIdentifier getReferenceName() {
|
184 | 206 | public String toString() {
|
185 | 207 | return getName() + " AS " + getAlias();
|
186 | 208 | }
|
| 209 | + |
| 210 | + @Override |
| 211 | + public boolean equals(Object o) { |
| 212 | + |
| 213 | + if (this == o) { |
| 214 | + return true; |
| 215 | + } |
| 216 | + if (o == null || getClass() != o.getClass()) { |
| 217 | + return false; |
| 218 | + } |
| 219 | + if (!super.equals(o)) { |
| 220 | + return false; |
| 221 | + } |
| 222 | + AliasedTable that = (AliasedTable) o; |
| 223 | + return alias.equals(that.alias); |
| 224 | + } |
| 225 | + |
| 226 | + @Override |
| 227 | + public int hashCode() { |
| 228 | + return Objects.hash(super.hashCode(), alias); |
| 229 | + } |
187 | 230 | }
|
188 | 231 | }
|
0 commit comments