Class NettyByteBufferFactory

java.lang.Object
io.micronaut.buffer.netty.NettyByteBufferFactory
All Implemented Interfaces:
ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>

@Internal @Singleton public final class NettyByteBufferFactory extends Object implements ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
A ByteBufferFactory implementation for Netty.
Since:
1.0
Author:
Graeme Rocher
  • Field Details

  • Constructor Details

    • NettyByteBufferFactory

      public NettyByteBufferFactory()
      Default constructor.
    • NettyByteBufferFactory

      public NettyByteBufferFactory(io.netty.buffer.ByteBufAllocator allocator)
      Parameters:
      allocator - The ByteBufAllocator
  • Method Details

    • getNativeAllocator

      public io.netty.buffer.ByteBufAllocator getNativeAllocator()
      Specified by:
      getNativeAllocator in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
      Returns:
      The native allocator
    • buffer

      public ByteBuffer<io.netty.buffer.ByteBuf> buffer()
      Description copied from interface: ByteBufferFactory
      Allocate a ByteBuffer. If it is a direct or heap buffer depends on the actual implementation.
      Specified by:
      buffer in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
      Returns:
      The buffer
    • buffer

      public ByteBuffer<io.netty.buffer.ByteBuf> buffer(int initialCapacity)
      Description copied from interface: ByteBufferFactory
      Allocate a ByteBuffer with the given initial capacity. If it is a direct or heap buffer depends on the actual implementation.
      Specified by:
      buffer in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
      Parameters:
      initialCapacity - The initial capacity
      Returns:
      the buffer
    • buffer

      public ByteBuffer<io.netty.buffer.ByteBuf> buffer(int initialCapacity, int maxCapacity)
      Description copied from interface: ByteBufferFactory
      Allocate a ByteBuffer with the given initial capacity and the given maximal capacity. If it is a direct or heap buffer depends on the actual implementation.
      Specified by:
      buffer in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
      Parameters:
      initialCapacity - The initial capacity
      maxCapacity - The maximum capacity
      Returns:
      The buffer
    • copiedBuffer

      public ByteBuffer<io.netty.buffer.ByteBuf> copiedBuffer(byte[] bytes)
      Description copied from interface: ByteBufferFactory
      Creates a new big-endian buffer whose content is a copy of the specified array's sub-region. The new buffer's readerIndex and writerIndex are 0 and the specified length respectively.
      Specified by:
      copiedBuffer in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
      Parameters:
      bytes - The bytes
      Returns:
      The buffer
    • copiedBuffer

      public ByteBuffer<io.netty.buffer.ByteBuf> copiedBuffer(ByteBuffer nioBuffer)
      Description copied from interface: ByteBufferFactory
      Creates a new big-endian buffer whose content is a copy of the specified NIO buffer. The new buffer's readerIndex and writerIndex are 0 and the specified length respectively.
      Specified by:
      copiedBuffer in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
      Parameters:
      nioBuffer - The nioBuffer
      Returns:
      The buffer
    • wrap

      public ByteBuffer<io.netty.buffer.ByteBuf> wrap(io.netty.buffer.ByteBuf existing)
      Description copied from interface: ByteBufferFactory
      Wrap an existing buffer.
      Specified by:
      wrap in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
      Parameters:
      existing - The buffer to wrap
      Returns:
      The wrapped ByteBuffer
    • wrap

      public ByteBuffer<io.netty.buffer.ByteBuf> wrap(byte[] existing)
      Description copied from interface: ByteBufferFactory
      Wrap an existing buffer.
      Specified by:
      wrap in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
      Parameters:
      existing - The bytes to wrap
      Returns:
      The wrapped ByteBuffer