ByteArray implements Comparable<ByteArray> { public static boolean equals(ByteArray array1, ByteArray array2) { if (array1 == null) { if (array2 == null) { return true; } else { return false; } } if (array2 == null) { return false; } if (array1.getArray() == null) { if (array2.getArray() == null) { return true; } else { return false; } } if (array2.getArray() == null) { return false; } return Arrays.equals(array1.getArray(), array2.getArray()); }  abstract byte[] getArray(); abstract int getLength(); abstract byte getAdjusted(int pos); static ByteArray wrap(byte[] array); static ByteArray wrap(byte[] array, int offset); static ByteArray wrap(byte[] array, int offset, int length); static boolean equals(ByteArray array1, ByteArray array2); boolean equals(Object o); static final ByteArrayComparator BYTE_ARRAY_COMPARATOR; }
@Test(groups = "fast") public void testEquals() throws Exception { Assert.assertFalse(byteArray1.equals(byteArray2)); Assert.assertFalse(byteArray2.equals(byteArray1)); Assert.assertTrue(byteArray1.equals(byteArray1)); Assert.assertFalse(byteArray1.equals(null)); Assert.assertFalse(nullArray.equals(null)); Assert.assertFalse(byteArray1.equals(nullArray)); Assert.assertFalse(nullArray.equals(byteArray1)); }