From 15ac6d2b8e83a73ac1f62ab0da0d6a85717f28fd Mon Sep 17 00:00:00 2001 From: Abhishek Koneru Date: Mon, 9 Jul 2012 15:12:11 -0400 Subject: NO_HASHCODE_OVERRIDDEN --- .../netscape/certsrv/base/MetaAttributeDef.java | 54 +++++++++++++--------- .../src/com/netscape/certsrv/util/StatsEvent.java | 2 +- 2 files changed, 34 insertions(+), 22 deletions(-) (limited to 'base/common/src/com/netscape/certsrv') diff --git a/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java b/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java index 63480478f..087110a0f 100644 --- a/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java +++ b/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java @@ -129,29 +129,41 @@ public class MetaAttributeDef { return newDef; } - /** - * Compares this attribute definition with another, for equality. - *

- * - * @return true iff names, valueClasses and object identifiers - * are identical. - */ - public boolean equals(Object other) { - if (other == this) - return true; - - if (other instanceof MetaAttributeDef) { - MetaAttributeDef otherDef = (MetaAttributeDef) other; + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((mName == null) ? 0 : mName.hashCode()); + result = prime * result + ((mOid == null) ? 0 : mOid.hashCode()); + result = prime * result + ((mValueClass == null) ? 0 : mValueClass.hashCode()); + return result; + } - if ((mOid != null && otherDef.mOid != null && - !mOid.equals(otherDef.mOid)) || - (mOid == null && otherDef.mOid != null) || - !mName.equals(otherDef.mName) || - !mValueClass.equals(otherDef.mValueClass)) { + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + MetaAttributeDef other = (MetaAttributeDef) obj; + if (mName == null) { + if (other.mName != null) return false; - } - } - return false; + } else if (!mName.equals(other.mName)) + return false; + if (mOid == null) { + if (other.mOid != null) + return false; + } else if (!mOid.equals(other.mOid)) + return false; + if (mValueClass == null) { + if (other.mValueClass != null) + return false; + } else if (!mValueClass.equals(other.mValueClass)) + return false; + return true; } /** diff --git a/base/common/src/com/netscape/certsrv/util/StatsEvent.java b/base/common/src/com/netscape/certsrv/util/StatsEvent.java index 4137aa3b2..07bbf9547 100644 --- a/base/common/src/com/netscape/certsrv/util/StatsEvent.java +++ b/base/common/src/com/netscape/certsrv/util/StatsEvent.java @@ -116,7 +116,7 @@ public class StatsEvent { long a = getTimeTakenSqSum(); long b = (-2 * getAvg() * getTimeTaken()); long c = getAvg() * getAvg() * getNoOfOperations(); - return (long) Math.sqrt((a + b + c) / getNoOfOperations()); + return (long) Math.sqrt(((double) (a + b + c)) / getNoOfOperations()); } } -- cgit