@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; AbstractKey<?> other = (AbstractKey<?>) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (table == null) { if (other.table != null) return false; } else if (!table.equals(other.table)) return false; return true; }
/** * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public final <O extends Record> List<ForeignKey<R, O>> getReferencesTo(Table<O> other) { List<ForeignKey<R, O>> result = new ArrayList<ForeignKey<R, O>>(); for (ForeignKey<R, ?> reference : getReferences()) { if (other.equals(reference.getKey().getTable())) { result.add((ForeignKey<R, O>) reference); } // [#1460] [#6304] In case the other table was aliased else { Table<O> aliased = Tools.aliased(other); if (aliased != null && aliased.equals(reference.getKey().getTable())) { result.add((ForeignKey<R, O>) reference); } } } return Collections.unmodifiableList(result); }
private final Table<?> search(Table<?> tree, Table<?> search) { // [#6304] Improved alias discovery Alias<? extends Table<?>> alias = Tools.alias(tree); if (alias != null) { return search(alias.wrapped(), search); } else if (tree instanceof JoinTable) { JoinTable t = (JoinTable) tree; Table<?> r = search(t.lhs, search); if (r == null) r = search(t.rhs, search); return r; } else { return search.equals(tree) ? tree : null; } }