Removing ArrayUtils.hashCode per LANG-492; it is now available as java.util.Arrays.hashCode
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@881685 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
87c4b35e52
commit
8550f4da08
|
@ -180,18 +180,6 @@ public class ArrayUtils {
|
||||||
return new ToStringBuilder(array, ToStringStyle.SIMPLE_STYLE).append(array).toString();
|
return new ToStringBuilder(array, ToStringStyle.SIMPLE_STYLE).append(array).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Get a hashCode for an array handling multi-dimensional arrays correctly.</p>
|
|
||||||
*
|
|
||||||
* <p>Multi-dimensional primitive arrays are also handled correctly by this method.</p>
|
|
||||||
*
|
|
||||||
* @param array the array to get a hashCode for, may be <code>null</code>
|
|
||||||
* @return a hashCode for the array, zero if null array input
|
|
||||||
*/
|
|
||||||
public static int hashCode(Object array) {
|
|
||||||
return new HashCodeBuilder().append(array).toHashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Compares two arrays, using equals(), handling multi-dimensional arrays
|
* <p>Compares two arrays, using equals(), handling multi-dimensional arrays
|
||||||
* correctly.</p>
|
* correctly.</p>
|
||||||
|
|
|
@ -92,19 +92,6 @@ public class ArrayUtilsTest extends TestCase {
|
||||||
assertEquals("{pink,blue}", ArrayUtils.toString(new String[] {"pink","blue"}, "<empty>"));
|
assertEquals("{pink,blue}", ArrayUtils.toString(new String[] {"pink","blue"}, "<empty>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
public void testHashCode() {
|
|
||||||
long[][] array1 = new long[][] {{2,5}, {4,5}};
|
|
||||||
long[][] array2 = new long[][] {{2,5}, {4,6}};
|
|
||||||
assertEquals(true, ArrayUtils.hashCode(array1) == ArrayUtils.hashCode(array1));
|
|
||||||
assertEquals(false, ArrayUtils.hashCode(array1) == ArrayUtils.hashCode(array2));
|
|
||||||
|
|
||||||
Object[] array3 = new Object[] {new String(new char[] {'A', 'B'})};
|
|
||||||
Object[] array4 = new Object[] {"AB"};
|
|
||||||
assertEquals(true, ArrayUtils.hashCode(array3) == ArrayUtils.hashCode(array3));
|
|
||||||
assertEquals(true, ArrayUtils.hashCode(array3) == ArrayUtils.hashCode(array4));
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
private void assertIsEquals(Object array1, Object array2, Object array3) {
|
private void assertIsEquals(Object array1, Object array2, Object array3) {
|
||||||
assertEquals(true, ArrayUtils.isEquals(array1, array1));
|
assertEquals(true, ArrayUtils.isEquals(array1, array1));
|
||||||
|
|
Loading…
Reference in New Issue