[#2347] Let equals() implementations succeed early on identity
This commit is contained in:
parent
c75ea9886b
commit
86bc2b5dc8
@ -191,6 +191,9 @@ public abstract class AbstractDefinition implements Definition {
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
||||
if (obj instanceof Definition) {
|
||||
Definition that = (Definition) obj;
|
||||
return that.getQualifiedName().equals(getQualifiedName());
|
||||
|
||||
@ -152,6 +152,9 @@ public class DefaultDataTypeDefinition implements DataTypeDefinition {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
||||
if (obj instanceof DefaultDataTypeDefinition) {
|
||||
DefaultDataTypeDefinition other = (DefaultDataTypeDefinition) obj;
|
||||
|
||||
|
||||
@ -1605,6 +1605,9 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// [#2144] Non-equality can be decided early, without executing the
|
||||
// rather expensive implementation of AbstractQueryPart.equals()
|
||||
|
||||
@ -85,9 +85,12 @@ abstract class AbstractQueryPart implements QueryPartInternal {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// This is a working default implementation. It should be overridden by
|
||||
// concrete subclasses, to improve performance
|
||||
|
||||
if (that instanceof QueryPart) {
|
||||
String sql1 = create().renderInlined(this);
|
||||
String sql2 = create().renderInlined((QueryPart) that);
|
||||
|
||||
@ -138,8 +138,11 @@ abstract class AbstractStore implements AttachableInternal {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
// Note: keep this implementation in-sync with AbstractRecord.compareTo()!
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Note: keep this implementation in-sync with AbstractRecord.compareTo()!
|
||||
if (obj instanceof AbstractStore) {
|
||||
final AbstractStore that = (AbstractStore) obj;
|
||||
|
||||
|
||||
@ -445,6 +445,9 @@ abstract class AbstractTable<R extends Record> extends AbstractQueryPart impleme
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// [#2144] Non-equality can be decided early, without executing the
|
||||
// rather expensive implementation of AbstractQueryPart.equals()
|
||||
|
||||
@ -110,6 +110,9 @@ public class CatalogImpl extends AbstractQueryPart implements Catalog {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// [#1626] CatalogImpl equality can be decided without executing the
|
||||
// rather expensive implementation of AbstractQueryPart.equals()
|
||||
|
||||
@ -75,6 +75,10 @@ class IdentityImpl<R extends Record, T> implements Identity<R, T> {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj instanceof Identity) {
|
||||
return toString().equals(obj.toString());
|
||||
}
|
||||
|
||||
@ -88,6 +88,9 @@ class NameImpl extends AbstractQueryPart implements Name {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// [#1626] NameImpl equality can be decided without executing the
|
||||
// rather expensive implementation of AbstractQueryPart.equals()
|
||||
|
||||
@ -99,6 +99,9 @@ public class PackageImpl extends AbstractQueryPart implements Package {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// [#1626] PackageImpl equality can be decided without executing the
|
||||
// rather expensive implementation of AbstractQueryPart.equals()
|
||||
|
||||
@ -109,6 +109,9 @@ class ParameterImpl<T> extends AbstractQueryPart implements Parameter<T> {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// [#1626] ParameterImpl equality can be decided without executing the
|
||||
// rather expensive implementation of AbstractQueryPart.equals()
|
||||
|
||||
@ -1191,6 +1191,10 @@ class ResultImpl<R extends Record> implements Result<R>, AttachableInternal {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj instanceof ResultImpl) {
|
||||
ResultImpl<R> other = (ResultImpl<R>) obj;
|
||||
return records.equals(other.records);
|
||||
|
||||
@ -155,6 +155,9 @@ public class SchemaImpl extends AbstractQueryPart implements Schema {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// [#2144] SchemaImpl equality can be decided without executing the
|
||||
// rather expensive implementation of AbstractQueryPart.equals()
|
||||
|
||||
@ -90,6 +90,9 @@ class TableFieldImpl<R extends Record, T> extends AbstractField<T> implements Ta
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// [#2144] TableFieldImpl equality can be decided without executing the
|
||||
// rather expensive implementation of AbstractQueryPart.equals()
|
||||
|
||||
@ -180,6 +180,9 @@ public class TableImpl<R extends Record> extends AbstractTable<R> {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// [#2144] TableImpl equality can be decided without executing the
|
||||
// rather expensive implementation of AbstractQueryPart.equals()
|
||||
|
||||
@ -69,7 +69,7 @@ class Value<T> implements Serializable {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final void intern() {
|
||||
|
||||
|
||||
// [#2177] Future versions of jOOQ may optimise this type check by
|
||||
// performing type-decisions outside of Value
|
||||
if (value instanceof String) {
|
||||
@ -135,6 +135,10 @@ class Value<T> implements Serializable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj instanceof Value<?>) {
|
||||
Value<?> other = (Value<?>) obj;
|
||||
|
||||
|
||||
@ -170,6 +170,8 @@ public final class ULong extends UNumber implements Comparable<ULong> {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj instanceof ULong) {
|
||||
return value.equals(((ULong) obj).value);
|
||||
}
|
||||
|
||||
@ -157,6 +157,8 @@ public final class UShort extends UNumber implements Comparable<UShort> {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj instanceof UShort) {
|
||||
return value == ((UShort) obj).value;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user