class GridH2RowRange implements Message {
    /** */
    private static int FLAG_PARTIAL = 1;

    /** */
    private int rangeId;

    /** */
    @GridDirectCollection(Message.class)
    @GridToStringInclude
    private List<GridH2RowMessage> rows;

    /** */
    private byte flags;

    /**
     * @param rangeId Range ID.
     */
    public void rangeId(int rangeId) {
        this.rangeId = rangeId;
    }

    /**
     * @return Range ID.
     */
    public int rangeId() {
        return rangeId;
    }

    /**
     * @param rows Rows.
     */
    public void rows(List<GridH2RowMessage> rows) {
        this.rows = rows;
    }

    /**
     * @return Rows.
     */
    public List<GridH2RowMessage> rows() {
        return rows;
    }

    /**
     * Sets that this is a partial range.
     */
    public void setPartial() {
        flags |= FLAG_PARTIAL;
    }

    /**
     * @return {@code true} If this is a partial range.
     */
    public boolean isPartial() {
        return (flags & FLAG_PARTIAL) == FLAG_PARTIAL;
    }

    /** {@inheritDoc} */
    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {<FILL_FUNCTION_BODY>}

    /** {@inheritDoc} */
    @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
        reader.setBuffer(buf);

        if (!reader.beforeMessageRead())
            return false;

        switch (reader.state()) {
            case 0:
                flags = reader.readByte("flags");

                if (!reader.isLastRead())
                    return false;

                reader.incrementState();

            case 1:
                rangeId = reader.readInt("rangeId");

                if (!reader.isLastRead())
                    return false;

                reader.incrementState();

            case 2:
                rows = reader.readCollection("rows", MessageCollectionItemType.MSG);

                if (!reader.isLastRead())
                    return false;

                reader.incrementState();

        }

        return reader.afterMessageRead(GridH2RowRange.class);
    }

    /** {@inheritDoc} */
    @Override public short directType() {
        return -34;
    }

    /** {@inheritDoc} */
    @Override public byte fieldsCount() {
        return 3;
    }

    /** {@inheritDoc} */
    @Override public void onAckReceived() {
        // No-op.
    }

    /**
     * @return Number of rows.
     */
    public int rowsSize() {
        return rows == null ? 0 : rows.size();
    }

    /** {@inheritDoc} */
    @Override public String toString() {
        return S.toString(GridH2RowRange.class, this, "rowsSize", rowsSize());
    }
}

        writer.setBuffer(buf);

        if (!writer.isHeaderWritten()) {
            if (!writer.writeHeader(directType(), fieldsCount()))
                return false;

            writer.onHeaderWritten();
        }

        switch (writer.state()) {
            case 0:
                if (!writer.writeByte("flags", flags))
                    return false;

                writer.incrementState();

            case 1:
                if (!writer.writeInt("rangeId", rangeId))
                    return false;

                writer.incrementState();

            case 2:
                if (!writer.writeCollection("rows", rows, MessageCollectionItemType.MSG))
                    return false;

                writer.incrementState();

        }

        return true;
    
<no_super_class>