Revert "[jOOQ/jOOQ#11867] Improve internal equals() and hashCode() implementations"
This commit is contained in:
parent
99322b54aa
commit
72209542a6
@ -47,7 +47,6 @@ import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jooq.Name;
|
||||
@ -388,7 +387,11 @@ public class DefaultDataTypeDefinition implements DataTypeDefinition {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(type, userType);
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
result = prime * result + ((userType == null) ? 0 : userType.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -49,7 +49,6 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jooq.tools.JooqLogger;
|
||||
@ -439,5 +438,51 @@ public class DefaultRelations implements Relations {
|
||||
/**
|
||||
* A simple local wrapper for a key definition (table + key name)
|
||||
*/
|
||||
private static final /* record */ class Key { private final TableDefinition table; private final String keyName; public Key(TableDefinition table, String keyName) { this.table = table; this.keyName = keyName; } public TableDefinition table() { return table; } public String keyName() { return keyName; } @Override public boolean equals(Object o) { if (!(o instanceof Key)) return false; Key other = (Key) o; if (!java.util.Objects.equals(this.table, other.table)) return false; if (!java.util.Objects.equals(this.keyName, other.keyName)) return false; return true; } @Override public int hashCode() { return java.util.Objects.hash(this.table, this.keyName); } @Override public String toString() { return new StringBuilder("Key[").append("table=").append(this.table).append(", keyName=").append(this.keyName).append("]").toString(); } }
|
||||
private static class Key {
|
||||
final TableDefinition table;
|
||||
final String keyName;
|
||||
|
||||
Key(TableDefinition table, String keyName) {
|
||||
this.table = table;
|
||||
this.keyName = keyName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Key [table=" + table + ", keyName=" + keyName + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((keyName == null) ? 0 : keyName.hashCode());
|
||||
result = prime * result + ((table == null) ? 0 : table.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Key other = (Key) obj;
|
||||
if (keyName == null) {
|
||||
if (other.keyName != null)
|
||||
return false;
|
||||
}
|
||||
else if (!keyName.equals(other.keyName))
|
||||
return false;
|
||||
if (table == null) {
|
||||
if (other.table != null)
|
||||
return false;
|
||||
}
|
||||
else if (!table.equals(other.table))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,6 +39,8 @@ package org.jooq;
|
||||
|
||||
import org.jooq.impl.DefaultRecordMapper;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A type producing records that can be mapped.
|
||||
*
|
||||
@ -49,27 +51,32 @@ public interface Mappable<R extends Record> {
|
||||
/**
|
||||
* Create a record mapper that extracts a value by field index.
|
||||
*/
|
||||
@NotNull
|
||||
RecordMapper<R, ?> mapper(int fieldIndex);
|
||||
|
||||
/**
|
||||
* Create a record mapper that extracts a value by field name.
|
||||
*/
|
||||
@NotNull
|
||||
RecordMapper<R, ?> mapper(String fieldName);
|
||||
|
||||
/**
|
||||
* Create a record mapper that extracts a value by field name.
|
||||
*/
|
||||
@NotNull
|
||||
RecordMapper<R, ?> mapper(Name fieldName);
|
||||
|
||||
/**
|
||||
* Create a record mapper that extracts a value by field reference.
|
||||
*/
|
||||
@NotNull
|
||||
<T> RecordMapper<R, T> mapper(Field<T> field);
|
||||
|
||||
/**
|
||||
* Create a record mapper that maps records to a new
|
||||
* {@link RecordQualifier#getRecordType()}.
|
||||
*/
|
||||
@NotNull
|
||||
<S extends Record> RecordMapper<R, S> mapper(Table<S> table);
|
||||
|
||||
/**
|
||||
@ -77,6 +84,7 @@ public interface Mappable<R extends Record> {
|
||||
* configured {@link Configuration#recordMapperProvider()} (the
|
||||
* {@link DefaultRecordMapper}, by default).
|
||||
*/
|
||||
@NotNull
|
||||
<E> RecordMapper<R, E> mapper(Configuration configuration, Class<? extends E> type);
|
||||
|
||||
}
|
||||
|
||||
@ -42,7 +42,6 @@ package org.jooq;
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -339,7 +338,13 @@ public final class TableOptions implements Serializable {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(onCommit, select, source, type);
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((onCommit == null) ? 0 : onCommit.hashCode());
|
||||
result = prime * result + ((select == null) ? 0 : select.hashCode());
|
||||
result = prime * result + ((source == null) ? 0 : source.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -351,10 +356,23 @@ public final class TableOptions implements Serializable {
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TableOptions other = (TableOptions) obj;
|
||||
return onCommit == other.onCommit
|
||||
&& Objects.equals(select, other.select)
|
||||
&& Objects.equals(source, other.source)
|
||||
&& type == other.type;
|
||||
if (onCommit != other.onCommit)
|
||||
return false;
|
||||
if (select == null) {
|
||||
if (other.select != null)
|
||||
return false;
|
||||
}
|
||||
else if (!select.equals(other.select))
|
||||
return false;
|
||||
if (source == null) {
|
||||
if (other.source != null)
|
||||
return false;
|
||||
}
|
||||
else if (!source.equals(other.source))
|
||||
return false;
|
||||
if (type != other.type)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -41,7 +41,6 @@ import static org.jooq.impl.Tools.anyMatch;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.jooq.Constraint;
|
||||
import org.jooq.ConstraintEnforcementStep;
|
||||
@ -121,7 +120,11 @@ abstract class AbstractKey<R extends Record> extends AbstractNamed implements Ke
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getQualifiedName(), table);
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + getQualifiedName().hashCode();
|
||||
result = prime * result + ((table == null) ? 0 : table.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -37,8 +37,6 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.jooq.Check;
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.Constraint;
|
||||
@ -102,7 +100,8 @@ final class CheckImpl<R extends Record> extends AbstractNamed implements Check<R
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + Objects.hash(getQualifiedName(), condition, table);
|
||||
result = prime * result + ((condition == null) ? 0 : condition.hashCode());
|
||||
result = prime * result + ((table == null) ? 0 : table.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -115,9 +114,21 @@ final class CheckImpl<R extends Record> extends AbstractNamed implements Check<R
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CheckImpl<?> other = (CheckImpl<?>) obj;
|
||||
return Objects.equals(getQualifiedName(), other.getQualifiedName())
|
||||
&& Objects.equals(condition, other.condition)
|
||||
&& Objects.equals(table, other.table);
|
||||
if (!getQualifiedName().equals(other.getQualifiedName()))
|
||||
return false;
|
||||
if (condition == null) {
|
||||
if (other.condition != null)
|
||||
return false;
|
||||
}
|
||||
else if (!condition.equals(other.condition))
|
||||
return false;
|
||||
if (table == null) {
|
||||
if (other.table != null)
|
||||
return false;
|
||||
}
|
||||
else if (!table.equals(other.table))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -209,7 +209,6 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
@ -3692,7 +3691,10 @@ final class Tools {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(method);
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((method == null) ? 0 : method.getName().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -55,7 +55,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Meta;
|
||||
@ -234,7 +233,10 @@ final class VersionImpl extends AbstractNode<Version> implements Version {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id());
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((id() == null) ? 0 : id().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -246,7 +248,13 @@ final class VersionImpl extends AbstractNode<Version> implements Version {
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
VersionImpl other = (VersionImpl) obj;
|
||||
return Objects.equals(id(), other.id());
|
||||
if (id() == null) {
|
||||
if (other.id() != null)
|
||||
return false;
|
||||
}
|
||||
else if (!id().equals(other.id()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
Reference in New Issue
Block a user