Interface NetworkBuffer.Builder
- Enclosing interface:
NetworkBuffer
public static sealed interface NetworkBuffer.Builder
Configures and creates buffers, obtained from
NetworkBuffer.builder(long).
A builder can be reused, and each call to build() creates a separate buffer.-
Method Summary
Modifier and TypeMethodDescriptionautoResize(@Nullable NetworkBuffer.AutoResize autoResize) Sets the resize strategy used when a write needs more room than the capacity.build()Creates a buffer with the configured capacity, resize strategy, and registries, with both indexes at 0.registry(@Nullable Registries registries) Sets the registries for types that need them.
-
Method Details
-
autoResize
Sets the resize strategy used when a write needs more room than the capacity.- Parameters:
autoResize- the resize strategy, ornullfor a buffer that does not grow- Returns:
- this builder
-
registry
Sets the registries for types that need them.- Parameters:
registries- the registries, ornullfor none- Returns:
- this builder
-
build
NetworkBuffer build()Creates a buffer with the configured capacity, resize strategy, and registries, with both indexes at 0. The buffer allocates native memory, which is freed once it is no longer reachable.- Returns:
- the new buffer
- Throws:
IllegalArgumentException- if the capacity is negative
-