Top Description Inners Methods
io.netty5.buffer

public Interface ComponentIterator<T extends ComponentIterator.Next & io.netty5.buffer.BufferComponent>

extends SafeCloseable
Known Direct Implementers
io.netty5.buffer.DefaultCompositeBuffer.CompositeComponentIterator, io.netty5.buffer.bytebuffer.NioBuffer, io.netty5.buffer.unsafe.UnsafeBuffer
Type Parameters
<T>
A type that implements Next and BufferComponent.
Imports
io.netty5.buffer.ComponentIterator.Next, io.netty5.util.SafeCloseable

A facade for iterating the readable or writable components of a Buffer.

Note

the iterator object must be closed after use. The easiest way to ensure this, is to use a try-with-resources clause.

The typical code pattern for using this API looks like the following:

try (var iteration = buffer.forEachComponent()) {
         for (var c = iteration.first(); c != null; c = c.next()) {
             ByteBuffer componentBuffer = c.readableBuffer();
             // ...
         }
     }
Note the use of the var keyword for local variables, which are required for correctly expressing the generic types used in the iteration. Following this code pattern will ensure that the components, and their parent buffer, will be correctly life-cycled.
See Also
Buffer#forEachComponent()

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
ComponentIterator.Next

This interface exposes external iteration on components.

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

The first component of the iteration, or null if there are no components.
first
()

Get the first component of the iteration, or null if there are no components.

public default T

Returns:

The first readable component of the iteration, or null if there are no readable components.
firstReadable
()

Get the first component of the iteration that has any bytes to read, or null if there are no components with any readable bytes.

public default T

Returns:

The first writable component of the iteration, or null if there are no writable components.
firstWritable
()

Get the first component of the iteration that has any space for writing bytes, or null if there are no components with any spare capacity.

private static <T extends ComponentIterator.Next & BufferComponent> T
nextReadable(T component)

private static <T extends ComponentIterator.Next & BufferComponent> T
nextWritable(T component)

Inherited from io.netty5.util.SafeCloseable:
close

Method Detail

firstback to summary
public T first()

Get the first component of the iteration, or null if there are no components.

The object returned will implement both of the Next and BufferComponent interfaces.

Returns:T

The first component of the iteration, or null if there are no components.

firstReadableback to summary
public default T firstReadable()

Get the first component of the iteration that has any bytes to read, or null if there are no components with any readable bytes.

The object returned will implement both of the Next and BufferComponent interfaces.

Returns:T

The first readable component of the iteration, or null if there are no readable components.

firstWritableback to summary
public default T firstWritable()

Get the first component of the iteration that has any space for writing bytes, or null if there are no components with any spare capacity.

The object returned will implement both of the Next and BufferComponent interfaces.

Returns:T

The first writable component of the iteration, or null if there are no writable components.

nextReadableback to summary
private static <T extends ComponentIterator.Next & BufferComponent> T nextReadable(T component)
nextWritableback to summary
private static <T extends ComponentIterator.Next & BufferComponent> T nextWritable(T component)