blob: a06e05698fb059fa5e63841d12c16894ff9ad35b [file] [log] [blame]
package com.google.net.stubby.newtransport.netty;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import java.nio.ByteBuffer;
/**
* Common utility methods.
*/
class Utils {
/**
* Copies the content of the given {@link ByteBuffer} to a new {@link ByteBuf} instance.
*/
static ByteBuf toByteBuf(ByteBufAllocator alloc, ByteBuffer source) {
ByteBuf buf = alloc.buffer(source.remaining());
buf.writeBytes(source);
return buf;
}
private Utils() {
// Prevents instantiation
}
}