@Test public void testCompare() { List<ByteBuf> expected = new ArrayList<ByteBuf>(); expected.add(wrappedBuffer(new byte[]{1})); expected.add(wrappedBuffer(new byte[]{1, 2})); expected.add(wrappedBuffer(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})); expected.add(wrappedBuffer(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12})); expected.add(wrappedBuffer(new byte[]{2})); expected.add(wrappedBuffer(new byte[]{2, 3})); expected.add(wrappedBuffer(new byte[]{2, 3, 4, 5, 6, 7, 8, 9, 10, 11})); expected.add(wrappedBuffer(new byte[]{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13})); expected.add(wrappedBuffer(new byte[]{2, 3, 4}, 1, 1)); expected.add(wrappedBuffer(new byte[]{1, 2, 3, 4}, 2, 2)); expected.add(wrappedBuffer(new byte[]{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 1, 10)); expected.add(wrappedBuffer(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 2, 12)); expected.add(wrappedBuffer(new byte[]{2, 3, 4, 5}, 2, 1)); expected.add(wrappedBuffer(new byte[]{1, 2, 3, 4, 5}, 3, 2)); expected.add(wrappedBuffer(new byte[]{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 2, 10)); expected.add(wrappedBuffer(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 3, 12)); for (int i = 0; i < expected.size(); i ++) { for (int j = 0; j < expected.size(); j ++) { if (i == j) { assertEquals(0, ByteBufUtil.compare(expected.get(i), expected.get(j))); } else if (i < j) { assertTrue(ByteBufUtil.compare(expected.get(i), expected.get(j)) < 0); } else { assertTrue(ByteBufUtil.compare(expected.get(i), expected.get(j)) > 0); } } } for (ByteBuf buffer: expected) { buffer.release(); } }
public static ByteBuf wrappedBuffer(byte[] array) { if (array.length == 0) { return EMPTY_BUFFER; } return new UnpooledHeapByteBuf(ALLOC, array, array.length); }
Unpooled { public static ByteBuf wrappedBuffer(byte[] array) { if (array.length == 0) { return EMPTY_BUFFER; } return new UnpooledHeapByteBuf(ALLOC, array, array.length); } }
Unpooled { public static ByteBuf wrappedBuffer(byte[] array) { if (array.length == 0) { return EMPTY_BUFFER; } return new UnpooledHeapByteBuf(ALLOC, array, array.length); } private  Unpooled(); }
Unpooled { public static ByteBuf wrappedBuffer(byte[] array) { if (array.length == 0) { return EMPTY_BUFFER; } return new UnpooledHeapByteBuf(ALLOC, array, array.length); } private  Unpooled(); static ByteBuf buffer(); static ByteBuf directBuffer(); static ByteBuf buffer(int initialCapacity); static ByteBuf directBuffer(int initialCapacity); static ByteBuf buffer(int initialCapacity, int maxCapacity); static ByteBuf directBuffer(int initialCapacity, int maxCapacity); static ByteBuf wrappedBuffer(byte[] array); static ByteBuf wrappedBuffer(byte[] array, int offset, int length); static ByteBuf wrappedBuffer(ByteBuffer buffer); static ByteBuf wrappedBuffer(long memoryAddress, int size, boolean doFree); static ByteBuf wrappedBuffer(ByteBuf buffer); static ByteBuf wrappedBuffer(byte[]... arrays); static ByteBuf wrappedBuffer(ByteBuf... buffers); static ByteBuf wrappedBuffer(ByteBuffer... buffers); static ByteBuf wrappedBuffer(int maxNumComponents, byte[]... arrays); static ByteBuf wrappedBuffer(int maxNumComponents, ByteBuf... buffers); static ByteBuf wrappedBuffer(int maxNumComponents, ByteBuffer... buffers); static CompositeByteBuf compositeBuffer(); static CompositeByteBuf compositeBuffer(int maxNumComponents); static ByteBuf copiedBuffer(byte[] array); static ByteBuf copiedBuffer(byte[] array, int offset, int length); static ByteBuf copiedBuffer(ByteBuffer buffer); static ByteBuf copiedBuffer(ByteBuf buffer); static ByteBuf copiedBuffer(byte[]... arrays); static ByteBuf copiedBuffer(ByteBuf... buffers); static ByteBuf copiedBuffer(ByteBuffer... buffers); static ByteBuf copiedBuffer(CharSequence string, Charset charset); static ByteBuf copiedBuffer(
            CharSequence string, int offset, int length, Charset charset); static ByteBuf copiedBuffer(char[] array, Charset charset); static ByteBuf copiedBuffer(char[] array, int offset, int length, Charset charset); @Deprecated static ByteBuf unmodifiableBuffer(ByteBuf buffer); static ByteBuf copyInt(int value); static ByteBuf copyInt(int... values); static ByteBuf copyShort(int value); static ByteBuf copyShort(short... values); static ByteBuf copyShort(int... values); static ByteBuf copyMedium(int value); static ByteBuf copyMedium(int... values); static ByteBuf copyLong(long value); static ByteBuf copyLong(long... values); static ByteBuf copyBoolean(boolean value); static ByteBuf copyBoolean(boolean... values); static ByteBuf copyFloat(float value); static ByteBuf copyFloat(float... values); static ByteBuf copyDouble(double value); static ByteBuf copyDouble(double... values); static ByteBuf unreleasableBuffer(ByteBuf buf); static ByteBuf unmodifiableBuffer(ByteBuf... buffers); }
Unpooled { public static ByteBuf wrappedBuffer(byte[] array) { if (array.length == 0) { return EMPTY_BUFFER; } return new UnpooledHeapByteBuf(ALLOC, array, array.length); } private  Unpooled(); static ByteBuf buffer(); static ByteBuf directBuffer(); static ByteBuf buffer(int initialCapacity); static ByteBuf directBuffer(int initialCapacity); static ByteBuf buffer(int initialCapacity, int maxCapacity); static ByteBuf directBuffer(int initialCapacity, int maxCapacity); static ByteBuf wrappedBuffer(byte[] array); static ByteBuf wrappedBuffer(byte[] array, int offset, int length); static ByteBuf wrappedBuffer(ByteBuffer buffer); static ByteBuf wrappedBuffer(long memoryAddress, int size, boolean doFree); static ByteBuf wrappedBuffer(ByteBuf buffer); static ByteBuf wrappedBuffer(byte[]... arrays); static ByteBuf wrappedBuffer(ByteBuf... buffers); static ByteBuf wrappedBuffer(ByteBuffer... buffers); static ByteBuf wrappedBuffer(int maxNumComponents, byte[]... arrays); static ByteBuf wrappedBuffer(int maxNumComponents, ByteBuf... buffers); static ByteBuf wrappedBuffer(int maxNumComponents, ByteBuffer... buffers); static CompositeByteBuf compositeBuffer(); static CompositeByteBuf compositeBuffer(int maxNumComponents); static ByteBuf copiedBuffer(byte[] array); static ByteBuf copiedBuffer(byte[] array, int offset, int length); static ByteBuf copiedBuffer(ByteBuffer buffer); static ByteBuf copiedBuffer(ByteBuf buffer); static ByteBuf copiedBuffer(byte[]... arrays); static ByteBuf copiedBuffer(ByteBuf... buffers); static ByteBuf copiedBuffer(ByteBuffer... buffers); static ByteBuf copiedBuffer(CharSequence string, Charset charset); static ByteBuf copiedBuffer(
            CharSequence string, int offset, int length, Charset charset); static ByteBuf copiedBuffer(char[] array, Charset charset); static ByteBuf copiedBuffer(char[] array, int offset, int length, Charset charset); @Deprecated static ByteBuf unmodifiableBuffer(ByteBuf buffer); static ByteBuf copyInt(int value); static ByteBuf copyInt(int... values); static ByteBuf copyShort(int value); static ByteBuf copyShort(short... values); static ByteBuf copyShort(int... values); static ByteBuf copyMedium(int value); static ByteBuf copyMedium(int... values); static ByteBuf copyLong(long value); static ByteBuf copyLong(long... values); static ByteBuf copyBoolean(boolean value); static ByteBuf copyBoolean(boolean... values); static ByteBuf copyFloat(float value); static ByteBuf copyFloat(float... values); static ByteBuf copyDouble(double value); static ByteBuf copyDouble(double... values); static ByteBuf unreleasableBuffer(ByteBuf buf); static ByteBuf unmodifiableBuffer(ByteBuf... buffers); static final ByteOrder BIG_ENDIAN; static final ByteOrder LITTLE_ENDIAN; static final ByteBuf EMPTY_BUFFER; }