Module io.netty5.buffer
Package io.netty5.buffer.api
Interface ComponentIterator<T extends ComponentIterator.Next>
-
- Type Parameters:
T- A type that implementsComponentIterator.Next, and eitherReadableComponentorWritableComponent.
- All Superinterfaces:
AutoCloseable,io.netty5.util.SafeCloseable
- All Known Implementing Classes:
SingleComponentIterator
public interface ComponentIterator<T extends ComponentIterator.Next> extends io.netty5.util.SafeCloseableA facade for iterating the readable or writable components of aBuffer. 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:
Note the use of thetry (var iteration = buffer.forEachReadable()) { for (var c = iteration.first(); c != null; c = c.next()) { ByteBuffer componentBuffer = c.readableBuffer(); // ... } }varkeyword 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.forEachReadable(),Buffer.forEachWritable()
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceComponentIterator.NextThis interface exposes external iteration on components.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Tfirst()Get the first component of the iteration, ornullif there are no components.
-
-
-
Method Detail
-
first
T first()
Get the first component of the iteration, ornullif there are no components.The object returned will implement both
ComponentIterator.Next, and one of theReadableComponentorWritableComponentinterfaces.- Returns:
- The first component of the iteration, or
nullif there are no components.
-
-