[#2144] Improve AbstractField.equals() and AbstractTable.equals() -
null-safe equals() checks
This commit is contained in:
parent
cfae02d9ab
commit
8f915549ca
@ -75,6 +75,7 @@ import org.jooq.SortOrder;
|
||||
import org.jooq.WindowIgnoreNullsStep;
|
||||
import org.jooq.WindowPartitionByStep;
|
||||
import org.jooq.tools.Convert;
|
||||
import org.jooq.tools.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
@ -1610,7 +1611,7 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
// [#2144] Non-equality can be decided early, without executing the
|
||||
// rather expensive implementation of AbstractQueryPart.equals()
|
||||
if (that instanceof AbstractField) {
|
||||
if (name.equals(((AbstractField<?>) that).name)) {
|
||||
if (StringUtils.equals(name, (((AbstractField<?>) that).name))) {
|
||||
return super.equals(that);
|
||||
}
|
||||
|
||||
|
||||
@ -59,6 +59,7 @@ import org.jooq.TableLike;
|
||||
import org.jooq.TableOnStep;
|
||||
import org.jooq.TableOptionalOnStep;
|
||||
import org.jooq.TablePartitionByStep;
|
||||
import org.jooq.tools.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
@ -421,7 +422,7 @@ abstract class AbstractTable<R extends Record> extends AbstractFieldProviderQuer
|
||||
// [#2144] Non-equality can be decided early, without executing the
|
||||
// rather expensive implementation of AbstractQueryPart.equals()
|
||||
if (that instanceof AbstractTable) {
|
||||
if (name.equals(((AbstractTable<?>) that).name)) {
|
||||
if (StringUtils.equals(name, (((AbstractTable<?>) that).name))) {
|
||||
return super.equals(that);
|
||||
}
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ import org.jooq.Schema;
|
||||
import org.jooq.Sequence;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.UDT;
|
||||
import org.jooq.tools.StringUtils;
|
||||
|
||||
/**
|
||||
* A common base class for database schemata
|
||||
@ -150,7 +151,7 @@ public class SchemaImpl extends AbstractQueryPart implements Schema {
|
||||
// [#2144] SchemaImpl equality can be decided without executing the
|
||||
// rather expensive implementation of AbstractQueryPart.equals()
|
||||
if (that instanceof SchemaImpl) {
|
||||
return getName().equals(((SchemaImpl) that).getName());
|
||||
return StringUtils.equals(getName(), (((SchemaImpl) that).getName()));
|
||||
}
|
||||
|
||||
return super.equals(that);
|
||||
|
||||
@ -42,6 +42,7 @@ import org.jooq.Record;
|
||||
import org.jooq.RenderContext;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableField;
|
||||
import org.jooq.tools.StringUtils;
|
||||
|
||||
/**
|
||||
* A common base type for table fields.
|
||||
@ -94,7 +95,9 @@ class TableFieldImpl<R extends Record, T> extends AbstractField<T> implements Ta
|
||||
// rather expensive implementation of AbstractQueryPart.equals()
|
||||
if (that instanceof TableField) {
|
||||
TableField<?, ?> other = (TableField<?, ?>) that;
|
||||
return getTable().equals(other.getTable()) && getName().equals(other.getName());
|
||||
return
|
||||
StringUtils.equals(getTable(), other.getTable()) &&
|
||||
StringUtils.equals(getName(), other.getName());
|
||||
}
|
||||
|
||||
return super.equals(that);
|
||||
|
||||
@ -185,7 +185,9 @@ public class TableImpl<R extends Record> extends AbstractTable<R> {
|
||||
// rather expensive implementation of AbstractQueryPart.equals()
|
||||
if (that instanceof TableImpl) {
|
||||
TableImpl<?> other = (TableImpl<?>) that;
|
||||
return StringUtils.equals(getSchema(), other.getSchema()) && getName().equals(other.getName());
|
||||
return
|
||||
StringUtils.equals(getSchema(), other.getSchema()) &&
|
||||
StringUtils.equals(getName(), other.getName());
|
||||
}
|
||||
|
||||
return super.equals(that);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user