class BoundedBitChannel implements BitChannel {

    public void write(boolean value) throws IOException {
        if (written + 1 <= maxBits) {
            channel.write(value);
            written += 1;
        } else {
            throw new IOException(OVERRUN_MESSAGE);
        }
    }

    public  BoundedBitChannel(@Nonnull BitChannel channel, @Nonnegative long maxBits);

}