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 | |
} | |
} |