@Test public void testEqualsWithDifferentLengthBinaryOfDifferentBytes() { int length1 = 10; Binary bin1 = createSteppedValueBinary(length1); Binary bin2 = createSteppedValueBinary(length1 + 1); assertFalse("Objects should not be equal", bin1.equals(bin2)); assertFalse("Objects should not be equal", bin2.equals(bin1)); }
@Override public final boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Binary buf = (Binary) o; final int size = _length; if (size != buf._length) { return false; } final byte[] myData = _data; final byte[] theirData = buf._data; int myOffset = _offset; int theirOffset = buf._offset; final int myLimit = myOffset + size; while(myOffset < myLimit) { if (myData[myOffset++] != theirData[theirOffset++]) { return false; } } return true; }
Binary { @Override public final boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Binary buf = (Binary) o; final int size = _length; if (size != buf._length) { return false; } final byte[] myData = _data; final byte[] theirData = buf._data; int myOffset = _offset; int theirOffset = buf._offset; final int myLimit = myOffset + size; while(myOffset < myLimit) { if (myData[myOffset++] != theirData[theirOffset++]) { return false; } } return true; } }
Binary { @Override public final boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Binary buf = (Binary) o; final int size = _length; if (size != buf._length) { return false; } final byte[] myData = _data; final byte[] theirData = buf._data; int myOffset = _offset; int theirOffset = buf._offset; final int myLimit = myOffset + size; while(myOffset < myLimit) { if (myData[myOffset++] != theirData[theirOffset++]) { return false; } } return true; } Binary(final byte[] data);  Binary(final byte[] data, final int offset, final int length); }
Binary { @Override public final boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Binary buf = (Binary) o; final int size = _length; if (size != buf._length) { return false; } final byte[] myData = _data; final byte[] theirData = buf._data; int myOffset = _offset; int theirOffset = buf._offset; final int myLimit = myOffset + size; while(myOffset < myLimit) { if (myData[myOffset++] != theirData[theirOffset++]) { return false; } } return true; } Binary(final byte[] data);  Binary(final byte[] data, final int offset, final int length); ByteBuffer asByteBuffer(); @Override final int hashCode(); @Override final boolean equals(Object o); int getArrayOffset(); byte[] getArray(); int getLength(); @Override String toString(); static Binary combine(final Collection<Binary> binaries); Binary subBinary(final int offset, final int length); static Binary create(ReadableBuffer buffer); static Binary create(ByteBuffer buffer); static Binary copy(Binary source); }
Binary { @Override public final boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Binary buf = (Binary) o; final int size = _length; if (size != buf._length) { return false; } final byte[] myData = _data; final byte[] theirData = buf._data; int myOffset = _offset; int theirOffset = buf._offset; final int myLimit = myOffset + size; while(myOffset < myLimit) { if (myData[myOffset++] != theirData[theirOffset++]) { return false; } } return true; } Binary(final byte[] data);  Binary(final byte[] data, final int offset, final int length); ByteBuffer asByteBuffer(); @Override final int hashCode(); @Override final boolean equals(Object o); int getArrayOffset(); byte[] getArray(); int getLength(); @Override String toString(); static Binary combine(final Collection<Binary> binaries); Binary subBinary(final int offset, final int length); static Binary create(ReadableBuffer buffer); static Binary create(ByteBuffer buffer); static Binary copy(Binary source);  }