HHH-7728 Add equals method in the table class

This commit is contained in:
Thorsten Schäfer 2012-10-29 11:18:11 +01:00 committed by brmeyer
parent 0e3fe2b3d5
commit e1ad7c51df
1 changed files with 21 additions and 0 deletions

View File

@ -328,6 +328,27 @@ public class Table implements RelationalModel, Serializable {
&& uniqueKey.getColumns().containsAll( primaryKey.getColumns() ); && uniqueKey.getColumns().containsAll( primaryKey.getColumns() );
} }
@Override
public int hashCode() {
return isQuoted() ? name.hashCode() : name.toLowerCase().hashCode();
}
@Override
public boolean equals(Object object) {
return object instanceof Table && equals((Table) object);
}
public boolean equals(Table table) {
if (null == table) {
return false;
}
if (this == table) {
return true;
}
return isQuoted() ? name.equals(table.getName()) : name.equalsIgnoreCase(table.getName());
}
public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) { public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) {
Iterator iter = getColumnIterator(); Iterator iter = getColumnIterator();
while ( iter.hasNext() ) { while ( iter.hasNext() ) {