code: @NotNull
  	public static ByteBuf ensureWriteRemaining(@NotNull ByteBuf buf, int minSize, int newWriteRemaining) {
  		if (newWriteRemaining == 0) return buf;
  		if (buf.writeRemaining() < newWriteRemaining || buf instanceof ByteBufSlice) {
  			ByteBuf newBuf = allocate(max(minSize, newWriteRemaining + buf.readRemaining()));
  			newBuf.put(buf);
  			buf.recycle();
  			return newBuf;
  		}
  		return buf;
  	}
docs: Checks if current ByteBuf can accommodate the needed
  amount of writable bytes.
  <p>
  Returns this ByteBuf, if it contains enough writable bytes.
  <p>
  Otherwise creates a new ByteBuf which contains data from the
  original ByteBuf and fits the parameters. Then recycles the
  original ByteBuf.
  
  @param buf the ByteBuf to check
  @param minSize the minimal size of the ByteBuf
  @param newWriteRemaining amount of needed writable bytes
  @return a ByteBuf which fits the parameters