From d39a5dcb1c9125cb832d8e189012be9767a419e5 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Tue, 6 Nov 2012 23:36:50 +0100 Subject: [PATCH] [#1937] Inefficient implementations of AbstractDataType.equals() and hashCode() --- .../java/org/jooq/impl/AbstractDataType.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java b/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java index 83e9dd9623..95ebc832be 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java @@ -526,11 +526,37 @@ public abstract class AbstractDataType implements DataType { @Override public int hashCode() { - return toString().hashCode(); + final int prime = 31; + int result = 1; + result = prime * result + ((dialect == null) ? 0 : dialect.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + result = prime * result + ((typeName == null) ? 0 : typeName.hashCode()); + return result; } @Override public boolean equals(Object obj) { - return toString().equals("" + obj); + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AbstractDataType other = (AbstractDataType) obj; + if (dialect != other.dialect) + return false; + if (type == null) { + if (other.type != null) + return false; + } + else if (!type.equals(other.type)) + return false; + if (typeName == null) { + if (other.typeName != null) + return false; + } + else if (!typeName.equals(other.typeName)) + return false; + return true; } }