private void generateFieldMutator(String className, FieldSpec field) {
        buffer.printf("%n");
        buffer.printf("public %s set%s(%s v) {%n",
            className,
            field.capitalizedCamelCaseName(),
            field.fieldAbstractJavaType(headerGenerator, structRegistry));
        buffer.incrementIndent();
        if (field.type() instanceof FieldType.Uint16FieldType) {
            buffer.printf("if (v < 0 || v > %d) {%n", MessageGenerator.UNSIGNED_SHORT_MAX);
            buffer.incrementIndent();
            buffer.printf("throw new RuntimeException(\"Invalid value \" + v + " +
                    "\" for unsigned short field.\");%n");
            buffer.decrementIndent();
            buffer.printf("}%n");
        }
        if (field.type() instanceof FieldType.Uint32FieldType) {
            buffer.printf("if (v < 0 || v > %dL) {%n", MessageGenerator.UNSIGNED_INT_MAX);
            buffer.incrementIndent();
            buffer.printf("throw new RuntimeException(\"Invalid value \" + v + " +
                    "\" for unsigned int field.\");%n");
            buffer.decrementIndent();
            buffer.printf("}%n");
        }
        buffer.printf("this.%s = v;%n", field.camelCaseName());
        buffer.printf("return this;%n");
        buffer.decrementIndent();
        buffer.printf("}%n");
    }
Generate the size calculator for a variable-length array element.
Array elements cannot be null.
generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java