mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-03-05 15:10:38 +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
|
// TODO: improve placeholder documentation
|
||||||
public class ByteInput {
|
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() {
|
public static ByteInput emptyByteInput() {
|
||||||
return EMPTY_BYTEINPUT;
|
return EMPTY_BYTEINPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ByteInput wrap(byte[] bytes) {
|
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 final ByteBuf buffer;
|
||||||
private BitInput bitInput;
|
private BitInput bitInput;
|
||||||
|
|
||||||
ByteInput(ByteBuf buffer) {
|
ByteInput(ByteBuf buffer) {
|
||||||
|
assert buffer.isReadOnly() : "buffer should be tagged ByteBuf#asReadOnly()";
|
||||||
this.buffer = buffer;
|
this.buffer = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user