Skip to content

Commit

Permalink
Let CompositeByteBuf implement Iterable
Browse files Browse the repository at this point in the history
Motivation:

CompositeByteBuf has an iterator() method but fails to implement Iterable

Modifications:

Let CompositeByteBuf implement Iterable<ByteBuf>

Result:

Easier usage
  • Loading branch information
normanmaurer committed Apr 12, 2015
1 parent aa1e537 commit 1862774
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* {@link ByteBufAllocator#compositeBuffer()} or {@link Unpooled#wrappedBuffer(ByteBuf...)} instead of calling the
* constructor explicitly.
*/
public class CompositeByteBuf extends AbstractReferenceCountedByteBuf {
public class CompositeByteBuf extends AbstractReferenceCountedByteBuf implements Iterable<ByteBuf> {

private static final ByteBuffer EMPTY_NIO_BUFFER = Unpooled.EMPTY_BUFFER.nioBuffer();

Expand Down Expand Up @@ -371,6 +371,7 @@ public CompositeByteBuf removeComponents(int cIndex, int numComponents) {
return this;
}

@Override
public Iterator<ByteBuf> iterator() {
ensureAccessible();
List<ByteBuf> list = new ArrayList<ByteBuf>(components.size());
Expand Down

0 comments on commit 1862774

Please sign in to comment.