mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-01-20 09:17:29 +07:00
Added ByteBuf read-only invariant
This commit is contained in:
parent
683d592c55
commit
7006ce9dc0
@ -18,19 +18,20 @@ import com.riiablo.util.DebugUtils;
|
||||
*/
|
||||
// TODO: improve placeholder documentation
|
||||
public class ByteInput {
|
||||
private static final ByteInput EMPTY_BYTEINPUT = new ByteInput(Unpooled.EMPTY_BUFFER);
|
||||
private static final ByteInput EMPTY_BYTEINPUT = new ByteInput(Unpooled.EMPTY_BUFFER.asReadOnly());
|
||||
public static ByteInput emptyByteInput() {
|
||||
return EMPTY_BYTEINPUT;
|
||||
}
|
||||
|
||||
public static ByteInput wrap(byte[] bytes) {
|
||||
return bytes == null ? emptyByteInput() : new ByteInput(Unpooled.wrappedBuffer(bytes));
|
||||
return bytes == null ? emptyByteInput() : new ByteInput(Unpooled.wrappedBuffer(bytes).asReadOnly());
|
||||
}
|
||||
|
||||
private final ByteBuf buffer;
|
||||
private BitInput bitInput;
|
||||
|
||||
ByteInput(ByteBuf buffer) {
|
||||
assert buffer.isReadOnly() : "buffer should be tagged ByteBuf#asReadOnly()";
|
||||
this.buffer = buffer;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user