Rolling back r611543 for LANG-393, and removing the special handling of BigDecimal to use compareTo instead of equals because it creates an inequality with HashCodeBuilder [reported in LANG-467 by David Jones]

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@836149 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2009-11-14 10:10:19 +00:00
parent 5646355247
commit 9adbbb0bbf
2 changed files with 2 additions and 14 deletions

View File

@ -377,12 +377,8 @@ public EqualsBuilder append(Object lhs, Object rhs) {
}
Class<?> lhsClass = lhs.getClass();
if (!lhsClass.isArray()) {
if (lhs instanceof java.math.BigDecimal && rhs instanceof java.math.BigDecimal) {
isEquals = (((java.math.BigDecimal)lhs).compareTo((java.math.BigDecimal)rhs) == 0);
} else {
// The simple case, not an array, just test the element
isEquals = lhs.equals(rhs);
}
} else if (lhs.getClass() != rhs.getClass()) {
// Here when we compare different dimensions, for example: a boolean[][] to a boolean[]
this.setEquals(false);

View File

@ -384,14 +384,6 @@ public void testFloat() {
assertTrue(new EqualsBuilder().append(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY).isEquals());
}
// https://issues.apache.org/jira/browse/LANG-393
public void testBigDecimal() {
BigDecimal o1 = new BigDecimal("2.0");
BigDecimal o2 = new BigDecimal("2.00");
assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
assertTrue(new EqualsBuilder().append(o1, o2).isEquals());
}
public void testAccessors() {
EqualsBuilder equalsBuilder = new EqualsBuilder();
assertTrue(equalsBuilder.isEquals());