@Test public void testAsIterator() { List<ByteBuf> expected = asList(wrapAscii("First"), wrapAscii("Second"), wrapAscii("Third"), wrapAscii("Fourth")); queue.addAll(expected); List<ByteBuf> actual = new ArrayList<>(); queue.asIterator().forEachRemaining(actual::add); assertEquals(expected, actual); }
@NotNull public Iterator<ByteBuf> asIterator() { if (!hasRemaining()) return emptyIterator(); ByteBufIterator iterator = new ByteBufIterator(this); first = last = 0; bufs = null; return iterator; }
ByteBufQueue implements Recyclable { @NotNull public Iterator<ByteBuf> asIterator() { if (!hasRemaining()) return emptyIterator(); ByteBufIterator iterator = new ByteBufIterator(this); first = last = 0; bufs = null; return iterator; } }
ByteBufQueue implements Recyclable { @NotNull public Iterator<ByteBuf> asIterator() { if (!hasRemaining()) return emptyIterator(); ByteBufIterator iterator = new ByteBufIterator(this); first = last = 0; bufs = null; return iterator; } ByteBufQueue();  ByteBufQueue(int capacity); }
ByteBufQueue implements Recyclable { @NotNull public Iterator<ByteBuf> asIterator() { if (!hasRemaining()) return emptyIterator(); ByteBufIterator iterator = new ByteBufIterator(this); first = last = 0; bufs = null; return iterator; } ByteBufQueue();  ByteBufQueue(int capacity); static Collector<ByteBuf, ByteBufQueue, ByteBuf> collector(); static Collector<ByteBuf, ByteBufQueue, ByteBuf> collector(int maxSize); void add(@NotNull ByteBuf buf); void addAll(@NotNull Iterable<ByteBuf> byteBufs); @NotNull ByteBuf take(); @Nullable ByteBuf poll(); @NotNull ByteBuf takeAtMost(int size); @NotNull ByteBuf takeAtLeast(int size); @NotNull ByteBuf takeAtLeast(int size, @NotNull Consumer<ByteBuf> recycled); @NotNull ByteBuf takeExactSize(int exactSize); @NotNull ByteBuf takeExactSize(int exactSize, @NotNull Consumer<ByteBuf> recycledBufs); void consume(int size, @NotNull Consumer<ByteBuf> consumer); @NotNull ByteBuf takeRemaining(); @Nullable @Contract(pure = true) ByteBuf peekBuf(); @NotNull @Contract(pure = true) ByteBuf peekBuf(int n); @Contract(pure = true) int remainingBufs(); @Contract(pure = true) int remainingBytes(); @Contract(pure = true) boolean isEmpty(); @Contract(pure = true) boolean hasRemaining(); @Contract(pure = true) boolean hasRemainingBytes(int remaining); byte getByte(); @Contract(pure = true) byte peekByte(); @Contract(pure = true) byte peekByte(int index); void setByte(int index, byte b); int skip(int maxSize); int skip(int maxSize, @NotNull Consumer<ByteBuf> recycledBufs); int drainTo(@NotNull byte[] dest, int destOffset, int maxSize); int drainTo(@NotNull byte[] dest, int destOffset, int maxSize, @NotNull Consumer<ByteBuf> recycledBufs); int drainTo(@NotNull ByteBuf dest, int maxSize); int drainTo(@NotNull ByteBuf dest); int drainTo(@NotNull ByteBufQueue dest); int drainTo(@NotNull Consumer<ByteBuf> dest); int drainTo(@NotNull ByteBufQueue dest, int maxSize); int drainTo(@NotNull Consumer<ByteBuf> dest, int maxSize); int scanBytes(ByteScanner byteScanner); int scanBytes(int offset, ByteScanner byteScanner); @NotNull Iterator<ByteBuf> asIterator(); boolean isRecycled(); @Override void recycle(); @Override String toString(); }
ByteBufQueue implements Recyclable { @NotNull public Iterator<ByteBuf> asIterator() { if (!hasRemaining()) return emptyIterator(); ByteBufIterator iterator = new ByteBufIterator(this); first = last = 0; bufs = null; return iterator; } ByteBufQueue();  ByteBufQueue(int capacity); static Collector<ByteBuf, ByteBufQueue, ByteBuf> collector(); static Collector<ByteBuf, ByteBufQueue, ByteBuf> collector(int maxSize); void add(@NotNull ByteBuf buf); void addAll(@NotNull Iterable<ByteBuf> byteBufs); @NotNull ByteBuf take(); @Nullable ByteBuf poll(); @NotNull ByteBuf takeAtMost(int size); @NotNull ByteBuf takeAtLeast(int size); @NotNull ByteBuf takeAtLeast(int size, @NotNull Consumer<ByteBuf> recycled); @NotNull ByteBuf takeExactSize(int exactSize); @NotNull ByteBuf takeExactSize(int exactSize, @NotNull Consumer<ByteBuf> recycledBufs); void consume(int size, @NotNull Consumer<ByteBuf> consumer); @NotNull ByteBuf takeRemaining(); @Nullable @Contract(pure = true) ByteBuf peekBuf(); @NotNull @Contract(pure = true) ByteBuf peekBuf(int n); @Contract(pure = true) int remainingBufs(); @Contract(pure = true) int remainingBytes(); @Contract(pure = true) boolean isEmpty(); @Contract(pure = true) boolean hasRemaining(); @Contract(pure = true) boolean hasRemainingBytes(int remaining); byte getByte(); @Contract(pure = true) byte peekByte(); @Contract(pure = true) byte peekByte(int index); void setByte(int index, byte b); int skip(int maxSize); int skip(int maxSize, @NotNull Consumer<ByteBuf> recycledBufs); int drainTo(@NotNull byte[] dest, int destOffset, int maxSize); int drainTo(@NotNull byte[] dest, int destOffset, int maxSize, @NotNull Consumer<ByteBuf> recycledBufs); int drainTo(@NotNull ByteBuf dest, int maxSize); int drainTo(@NotNull ByteBuf dest); int drainTo(@NotNull ByteBufQueue dest); int drainTo(@NotNull Consumer<ByteBuf> dest); int drainTo(@NotNull ByteBufQueue dest, int maxSize); int drainTo(@NotNull Consumer<ByteBuf> dest, int maxSize); int scanBytes(ByteScanner byteScanner); int scanBytes(int offset, ByteScanner byteScanner); @NotNull Iterator<ByteBuf> asIterator(); boolean isRecycled(); @Override void recycle(); @Override String toString();  }