// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstants.java
// static int mask(final int size) {
//     return MASKS[size - 1];
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeByte(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Byte.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Byte.SIZE);
//     }
//     if (unsigned && size == Byte.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned byte");
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeChar(final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Character.SIZE) {
//         throw new IllegalArgumentException("size(" + size + ") > " + Character.SIZE);
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeInt(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Integer.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Integer.SIZE);
//     }
//     if (unsigned && size == Integer.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned integer");
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeLong(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Long.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Long.SIZE);
//     }
//     if (unsigned && size == Long.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned long");
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeShort(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Short.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Short.SIZE);
//     }
//     if (unsigned && size == Short.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned short");
//     }
//     return size;
// }


import java.io.IOException;
import static com.github.jinahya.bit.io.BitIoConstants.mask;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeByte;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeChar;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeInt;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeLong;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeShort;
    @Override
    public void writeByte(final boolean unsigned, final int size, final byte value) throws IOException {
        writeInt(unsigned, requireValidSizeByte(unsigned, size), value);
    }

    @Override
    public void writeByte8(final byte value) throws IOException {
        writeByte(false, Byte.SIZE, value);
    }

    // ----------------------------------------------------------------------------------------------------------- short
    @Override
    public void writeShort(final boolean unsigned, final int size, final short value) throws IOException {
        writeInt(unsigned, requireValidSizeShort(unsigned, size), value);
    }

    @Override
    public void writeShort16(final short value) throws IOException {
        writeShort(false, Short.SIZE, value);
    }

    @Override
    public void writeShort16Le(final short value) throws IOException {
        writeByte8((byte) value);
        writeByte8((byte) (value >> Byte.SIZE));
    }

    // ------------------------------------------------------------------------------------------------------------- int
    @Override
    public void writeInt(final boolean unsigned, int size, final int value) throws IOException {
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstants.java
// static int mask(final int size) {
//     return MASKS[size - 1];
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeByte(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Byte.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Byte.SIZE);
//     }
//     if (unsigned && size == Byte.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned byte");
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeChar(final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Character.SIZE) {
//         throw new IllegalArgumentException("size(" + size + ") > " + Character.SIZE);
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeInt(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Integer.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Integer.SIZE);
//     }
//     if (unsigned && size == Integer.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned integer");
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeLong(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Long.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Long.SIZE);
//     }
//     if (unsigned && size == Long.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned long");
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeShort(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Short.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Short.SIZE);
//     }
//     if (unsigned && size == Short.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned short");
//     }
//     return size;
// }


// Path: src/main/java/com/github/jinahya/bit/io/AbstractBitOutput.java
import java.io.IOException;
import static com.github.jinahya.bit.io.BitIoConstants.mask;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeByte;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeChar;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeInt;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeLong;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeShort;

    @Override
    public void writeByte(final boolean unsigned, final int size, final byte value) throws IOException {
        writeInt(unsigned, requireValidSizeByte(unsigned, size), value);
    }

    @Override
    public void writeByte8(final byte value) throws IOException {
        writeByte(false, Byte.SIZE, value);
    }

    // ----------------------------------------------------------------------------------------------------------- short
    @Override
    public void writeShort(final boolean unsigned, final int size, final short value) throws IOException {
        writeInt(unsigned, requireValidSizeShort(unsigned, size), value);
    }

    @Override
    public void writeShort16(final short value) throws IOException {
        writeShort(false, Short.SIZE, value);
    }

    @Override
    public void writeShort16Le(final short value) throws IOException {
        writeByte8((byte) value);
        writeByte8((byte) (value >> Byte.SIZE));
    }

    // ------------------------------------------------------------------------------------------------------------- int
    @Override
    public void writeInt(final boolean unsigned, int size, final int value) throws IOException {
        requireValidSizeInt(unsigned, size);