@Test public void testEqualObjectsHaveEqualHash() { Object[] data = { TestData.getText(), TestData.getValue(), TestData.getPrimaryKey() }; ByteBuffer a = TArrays.hash(data); ByteBuffer b = TArrays.hash(data); Assert.assertEquals(a, b); }
public static ByteBuffer hash(Object... objects) { ByteBuffer bytes = ByteBuffer.allocate(8 * objects.length); for (Object object : objects) { bytes.putInt(object.hashCode()); bytes.putInt(object.getClass().getName().hashCode()); } bytes.rewind(); return bytes; }
TArrays { public static ByteBuffer hash(Object... objects) { ByteBuffer bytes = ByteBuffer.allocate(8 * objects.length); for (Object object : objects) { bytes.putInt(object.hashCode()); bytes.putInt(object.getClass().getName().hashCode()); } bytes.rewind(); return bytes; } }
TArrays { public static ByteBuffer hash(Object... objects) { ByteBuffer bytes = ByteBuffer.allocate(8 * objects.length); for (Object object : objects) { bytes.putInt(object.hashCode()); bytes.putInt(object.getClass().getName().hashCode()); } bytes.rewind(); return bytes; }  }
TArrays { public static ByteBuffer hash(Object... objects) { ByteBuffer bytes = ByteBuffer.allocate(8 * objects.length); for (Object object : objects) { bytes.putInt(object.hashCode()); bytes.putInt(object.getClass().getName().hashCode()); } bytes.rewind(); return bytes; }  static ByteBuffer hash(Object... objects); }
TArrays { public static ByteBuffer hash(Object... objects) { ByteBuffer bytes = ByteBuffer.allocate(8 * objects.length); for (Object object : objects) { bytes.putInt(object.hashCode()); bytes.putInt(object.getClass().getName().hashCode()); } bytes.rewind(); return bytes; }  static ByteBuffer hash(Object... objects);  }