AbstractValueHolder implements ValueHolder { @Override public boolean equals(Object obj) { if (obj != null && obj.getClass() == this.getClass()) { Object v1 = getValue(); Object v2 = ((ValueHolder) obj).getValue(); if (v1 == null) { return v2 == null; } if (v2 != null) { return v1.equals(v2); } } return false; }  @Override boolean isNull(); @Override boolean isNotNull(); @Override boolean equals(Object obj); @Override int hashCode(); @Override boolean isComparable(); @Override @SuppressWarnings("unchecked") int compareTo(ValueHolder o); @Override String toString(); @Override String getString(); @Override int intValue(); @Override long longValue(); @Override double doubleValue(); @Override boolean booleanValue(); @Override Integer getInteger(); @Override Long getLong(); @Override Double getDouble(); @Override Boolean getBoolean(); @Override BigDecimal getBigDecimal(); @Override Date getDate();  }
@Test public void testEquals() { Object[][] pairs = { {new StringHolder("ab"), new StringHolder("ab"), true}, {new StringHolder("ab"), new StringHolder("ac"), false}, {new IntegerHolder(1L), new IntegerHolder(1L), true}, {new IntegerHolder(1L), new StringHolder("1"), false}, {new StringHolder("ab"), null, false} }; for (int i = 0; i < pairs.length; i++) { Object[] test = pairs[i]; ValueHolder h1 = (ValueHolder) test[0]; ValueHolder h2 = (ValueHolder) test[1]; boolean expectedResult = (Boolean) test[2]; boolean result = h1.equals(h2); assertEquals(expectedResult, result); if (h2 != null) { result = h2.equals(h1); assertEquals(expectedResult, result); } } }