@Test public void testCompareToForNotEqualArrays() { byte[] a = new byte[] {1, 2, 3}; byte[] b = new byte[] {2, 3, 1}; assertTrue(new ByteArray(a).compareTo(new ByteArray(b)) < 0); }
@Override public int compareTo(ByteArray that) { int thisLength = this.byteArrayValue().length; int res = thisLength - that.byteArrayValue().length; if (res != 0) return res; for (int i = 0; i < thisLength; i++) { res = this.byteArrayValue()[i] - that.byteArrayValue()[i]; if (res != 0) return res; } return 0; }
ByteArray implements Comparable<ByteArray> { @Override public int compareTo(ByteArray that) { int thisLength = this.byteArrayValue().length; int res = thisLength - that.byteArrayValue().length; if (res != 0) return res; for (int i = 0; i < thisLength; i++) { res = this.byteArrayValue()[i] - that.byteArrayValue()[i]; if (res != 0) return res; } return 0; } }
ByteArray implements Comparable<ByteArray> { @Override public int compareTo(ByteArray that) { int thisLength = this.byteArrayValue().length; int res = thisLength - that.byteArrayValue().length; if (res != 0) return res; for (int i = 0; i < thisLength; i++) { res = this.byteArrayValue()[i] - that.byteArrayValue()[i]; if (res != 0) return res; } return 0; } ByteArray(byte... a); }
ByteArray implements Comparable<ByteArray> { @Override public int compareTo(ByteArray that) { int thisLength = this.byteArrayValue().length; int res = thisLength - that.byteArrayValue().length; if (res != 0) return res; for (int i = 0; i < thisLength; i++) { res = this.byteArrayValue()[i] - that.byteArrayValue()[i]; if (res != 0) return res; } return 0; } ByteArray(byte... a); byte[] byteArrayValue(); @Override boolean equals(Object thatObject); @Override int hashCode(); @Override String toString(); @Override int compareTo(ByteArray that); }
ByteArray implements Comparable<ByteArray> { @Override public int compareTo(ByteArray that) { int thisLength = this.byteArrayValue().length; int res = thisLength - that.byteArrayValue().length; if (res != 0) return res; for (int i = 0; i < thisLength; i++) { res = this.byteArrayValue()[i] - that.byteArrayValue()[i]; if (res != 0) return res; } return 0; } ByteArray(byte... a); byte[] byteArrayValue(); @Override boolean equals(Object thatObject); @Override int hashCode(); @Override String toString(); @Override int compareTo(ByteArray that);  }