/** * Creates the frame with a stream id. * * @param byteBuf the {@link ByteBuf} representing the frame * @return the frame with a stream id * @throws NullPointerException if {@code byteBuf} is {@code null} */ public static StreamIdFrame createStreamIdFrame(ByteBuf byteBuf) { Objects.requireNonNull(byteBuf, "byteBuf must not be null"); return RECYCLER.get().setByteBuf(byteBuf.retain()); }
/** * Creates the frame with a stream id. * * @param byteBufAllocator the {@code ByteBufAllocator} to use * @param streamId the stream id * @param frame the frame to prepend the stream id to * @return the frame with a stream id * @throws NullPointerException if {@code byteBufAllocator} or {@code frame} is {@code null} */ public static StreamIdFrame createStreamIdFrame( ByteBufAllocator byteBufAllocator, int streamId, Frame frame) { Objects.requireNonNull(byteBufAllocator, "byteBufAllocator must not be null"); Objects.requireNonNull(frame, "frame must not be null"); ByteBuf streamIdByteBuf = frame.mapFrame( frameByteBuf -> { ByteBuf byteBuf = byteBufAllocator.buffer(STREAM_ID_BYTES).writeInt(streamId); return Unpooled.wrappedBuffer(byteBuf, frameByteBuf.retain()); }); return RECYCLER.get().setByteBuf(streamIdByteBuf); }
/** * Creates the frame with a stream id. * * @param byteBuf the {@link ByteBuf} representing the frame * @return the frame with a stream id * @throws NullPointerException if {@code byteBuf} is {@code null} */ public static StreamIdFrame createStreamIdFrame(ByteBuf byteBuf) { Objects.requireNonNull(byteBuf, "byteBuf must not be null"); return RECYCLER.get().setByteBuf(byteBuf.retain()); }
/** * Creates the frame with a stream id. * * @param byteBufAllocator the {@code ByteBufAllocator} to use * @param streamId the stream id * @param frame the frame to prepend the stream id to * @return the frame with a stream id * @throws NullPointerException if {@code byteBufAllocator} or {@code frame} is {@code null} */ public static StreamIdFrame createStreamIdFrame( ByteBufAllocator byteBufAllocator, int streamId, Frame frame) { Objects.requireNonNull(byteBufAllocator, "byteBufAllocator must not be null"); Objects.requireNonNull(frame, "frame must not be null"); ByteBuf streamIdByteBuf = frame.mapFrame( frameByteBuf -> { ByteBuf byteBuf = byteBufAllocator.buffer(STREAM_ID_BYTES).writeInt(streamId); return Unpooled.wrappedBuffer(byteBuf, frameByteBuf.retain()); }); return RECYCLER.get().setByteBuf(streamIdByteBuf); }