Skip to content

Conversation

@li-enguyen
Copy link
Collaborator

@li-enguyen li-enguyen commented May 22, 2025

Summary: Updating CodeTransformations to modify generated java code to enable conversions between ints and long fields.

Changes:

  • enhanceNumericPutMethod: update public void put(int field$, java.lang.Object value$) method to allow setting int/Integer fields using long/Long objects, and vice versa
  • addOverloadedNumericSetterMethods: add overloaded setters to allow setting Int/Integer fields using long/Longs and vice versa
  • addOverloadedNumericConstructor: add overloaded constructor methods to allow int field to be set using long param, and vice versa
  • addOverloadedNumericBuilderSetterMethods : add overloaded setters for builder class
java file before change avro1_10
package under110;

import org.apache.avro.generic.GenericArray;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.util.Utf8;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;






public class IntsAndLongs extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
  private static final long serialVersionUID = 1471512375847052441L;
  public static final org.apache.avro.Schema SCHEMA$ = AvroCompatibilityHelper.parse("{\"type\":\"record\",\"name\":\"IntsAndLongs\",\"namespace\":\"under110\",\"fields\":[{\"name\":\"longField\",\"type\":\"long\"},{\"name\":\"intField\",\"type\":\"int\"},{\"name\":\"boxedLongField\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"boxedIntField\",\"type\":[\"null\",\"int\"],\"default\":null}]}");
  public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }

  private static final org.apache.avro.specific.SpecificData MODEL$ = SpecificData.get();

  

   public long longField;
   public int intField;
   public java.lang.Long boxedLongField;
   public java.lang.Integer boxedIntField;

  /**
   * Default constructor.  Note that this does not initialize fields
   * to their default values from the schema.  If that is desired then
   * one should use <code>newBuilder()</code>.
   */
  public IntsAndLongs() {}

  /**
   * All-args constructor.
   * @param longField The new value for longField
   * @param intField The new value for intField
   * @param boxedLongField The new value for boxedLongField
   * @param boxedIntField The new value for boxedIntField
   */
  public IntsAndLongs(java.lang.Long longField, java.lang.Integer intField, java.lang.Long boxedLongField, java.lang.Integer boxedIntField) {
    this.longField = longField;
    this.intField = intField;
    this.boxedLongField = boxedLongField;
    this.boxedIntField = boxedIntField;
  }

  public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }
  public org.apache.avro.Schema getSchema() { return SCHEMA$; }
  // Used by DatumWriter.  Applications should not call.
  public java.lang.Object get(int field$) {
    switch (field$) {
    case 0: return longField;
    case 1: return intField;
    case 2: return boxedLongField;
    case 3: return boxedIntField;
    default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
    }
  }

  // Used by DatumReader.  Applications should not call.
  @SuppressWarnings(value="unchecked")
  public void put(int field$, java.lang.Object value$) {
    switch (field$) {
    case 0: longField = (java.lang.Long)value$; break;
    case 1: intField = (java.lang.Integer)value$; break;
    case 2: boxedLongField = (java.lang.Long)value$; break;
    case 3: boxedIntField = (java.lang.Integer)value$; break;
    default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
    }
  }

  /**
   * Gets the value of the 'longField' field.
   * @return The value of the 'longField' field.
   */
  public long getLongField() {
    return longField;
  }


  /**
   * Sets the value of the 'longField' field.
   * @param value the value to set.
   */
  public void setLongField(long value) {
    this.longField = value;
  }

  /**
   * Gets the value of the 'intField' field.
   * @return The value of the 'intField' field.
   */
  public int getIntField() {
    return intField;
  }


  /**
   * Sets the value of the 'intField' field.
   * @param value the value to set.
   */
  public void setIntField(int value) {
    this.intField = value;
  }

  /**
   * Gets the value of the 'boxedLongField' field.
   * @return The value of the 'boxedLongField' field.
   */
  public java.lang.Long getBoxedLongField() {
    return boxedLongField;
  }


  /**
   * Sets the value of the 'boxedLongField' field.
   * @param value the value to set.
   */
  public void setBoxedLongField(java.lang.Long value) {
    this.boxedLongField = value;
  }

  /**
   * Gets the value of the 'boxedIntField' field.
   * @return The value of the 'boxedIntField' field.
   */
  public java.lang.Integer getBoxedIntField() {
    return boxedIntField;
  }


  /**
   * Sets the value of the 'boxedIntField' field.
   * @param value the value to set.
   */
  public void setBoxedIntField(java.lang.Integer value) {
    this.boxedIntField = value;
  }

  

  @SuppressWarnings("unchecked")
  private static final org.apache.avro.io.DatumWriter<IntsAndLongs>
    WRITER$ = AvroCompatibilityHelper.newSpecificDatumWriter(SCHEMA$, MODEL$);

  public void writeExternal(java.io.ObjectOutput out)
    throws java.io.IOException {
    WRITER$.write(this, AvroCompatibilityHelper.newBinaryEncoder(out));
  }

  @SuppressWarnings("unchecked")
  private static final org.apache.avro.io.DatumReader<IntsAndLongs>
    READER$ = AvroCompatibilityHelper.newSpecificDatumReader(SCHEMA$, SCHEMA$, MODEL$);

  public void readExternal(java.io.ObjectInput in)
    throws java.io.IOException {
    READER$.read(this, AvroCompatibilityHelper.newBinaryDecoder(in));
  }

  
}
java file after change avro1_10
package under110;

import org.apache.avro.generic.GenericArray;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.util.Utf8;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;






public class IntsAndLongs extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
  private static final long serialVersionUID = 1471512375847052441L;
  public static final org.apache.avro.Schema SCHEMA$ = AvroCompatibilityHelper.parse("{\"type\":\"record\",\"name\":\"IntsAndLongs\",\"namespace\":\"under110\",\"fields\":[{\"name\":\"longField\",\"type\":\"long\"},{\"name\":\"intField\",\"type\":\"int\"},{\"name\":\"boxedLongField\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"boxedIntField\",\"type\":[\"null\",\"int\"],\"default\":null}]}");
  public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }

  private static final org.apache.avro.specific.SpecificData MODEL$ = SpecificData.get();

  

   public long longField;
   public int intField;
   public java.lang.Long boxedLongField;
   public java.lang.Integer boxedIntField;

  /**
   * Default constructor.  Note that this does not initialize fields
   * to their default values from the schema.  If that is desired then
   * one should use <code>newBuilder()</code>.
   */
  public IntsAndLongs() {}

  /**
   * All-args constructor.
   * @param longField The new value for longField
   * @param intField The new value for intField
   * @param boxedLongField The new value for boxedLongField
   * @param boxedIntField The new value for boxedIntField
   */
  public IntsAndLongs(java.lang.Long longField, java.lang.Integer intField, java.lang.Long boxedLongField, java.lang.Integer boxedIntField) {
    this.longField = longField;
    this.intField = intField;
    this.boxedLongField = boxedLongField;
    this.boxedIntField = boxedIntField;
  }

  /**
   * All-args constructor with flexible numeric type conversion.
   * Allows Integer parameters for Long fields and Long parameters for Integer fields.
   * @param longField The new value for longField
   * @param intField The new value for intField
   * @param boxedLongField The new value for boxedLongField
   * @param boxedIntField The new value for boxedIntField
   */
  public IntsAndLongs(java.lang.Integer longField, java.lang.Long intField, java.lang.Integer boxedLongField, java.lang.Long boxedIntField) {
    this.longField = longField == null ? 0L : longField.longValue();
    if (intField == null) {
      this.intField = 0;
    } else if (intField <= Integer.MAX_VALUE && intField >= Integer.MIN_VALUE) {
      this.intField = intField.intValue();
    } else {
      throw new org.apache.avro.AvroRuntimeException("Long value " + intField + " cannot be cast to int");
    }
    if (boxedLongField == null) {
      this.boxedLongField = null;
    } else {
      this.boxedLongField = boxedLongField.longValue();
    }
    if (boxedIntField == null) {
      this.boxedIntField = null;
    } else if (boxedIntField <= Integer.MAX_VALUE && boxedIntField >= Integer.MIN_VALUE) {
      this.boxedIntField = boxedIntField.intValue();
    } else {
      throw new org.apache.avro.AvroRuntimeException("Long value " + boxedIntField + " cannot be cast to Integer");
    }
  }

  public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }
  public org.apache.avro.Schema getSchema() { return SCHEMA$; }
  // Used by DatumWriter.  Applications should not call.
  public java.lang.Object get(int field$) {
    switch (field$) {
    case 0: return longField;
    case 1: return intField;
    case 2: return boxedLongField;
    case 3: return boxedIntField;
    default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
    }
  }

  // Used by DatumReader.  Applications should not call.
  @SuppressWarnings(value="unchecked")
  public void put(int field$, java.lang.Object value$) {
  switch (field$) {
  case 0: if (value$ instanceof java.lang.Integer) {
      this.longField = ((java.lang.Integer)value$).longValue();
    } else {
      this.longField = (java.lang.Long)value$;
    }
    break;
  case 1: if (value$ instanceof java.lang.Long) {
      if ((java.lang.Long)value$ <= Integer.MAX_VALUE && (java.lang.Long)value$ >= Integer.MIN_VALUE) {
        this.intField = ((java.lang.Long)value$).intValue();
      } else {
        throw new org.apache.avro.AvroRuntimeException("Long value " + value$ + " cannot be cast to Integer");
      }
    } else {
      this.intField = (java.lang.Integer)value$;
    }
    break;
  case 2: if (value$ instanceof java.lang.Integer) {
      this.boxedLongField = ((java.lang.Integer)value$).longValue();
    } else {
      this.boxedLongField = (java.lang.Long)value$;
    }
    break;
  case 3: if (value$ instanceof java.lang.Long) {
      if ((java.lang.Long)value$ <= Integer.MAX_VALUE && (java.lang.Long)value$ >= Integer.MIN_VALUE) {
        this.boxedIntField = ((java.lang.Long)value$).intValue();
      } else {
        throw new org.apache.avro.AvroRuntimeException("Long value " + value$ + " cannot be cast to Integer");
      }
    } else {
      this.boxedIntField = (java.lang.Integer)value$;
    }
    break;
  default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
  }
}

  /**
   * Gets the value of the 'longField' field.
   * @return The value of the 'longField' field.
   */
  public long getLongField() {
    return longField;
  }


  /**
   * Sets the value of the 'longField' field.
   * @param value the value to set.
   */
  public void setLongField(long value) {
    this.longField = value;
  }

    /**
     * Sets longField to the specified value.
     * Accepts an int value and converts it to long.
     * @param value The int value to set
     */
    public void setLongField(int value) {
        setLongField((long) value);
    }

  /**
   * Gets the value of the 'intField' field.
   * @return The value of the 'intField' field.
   */
  public int getIntField() {
    return intField;
  }


  /**
   * Sets the value of the 'intField' field.
   * @param value the value to set.
   */
  public void setIntField(int value) {
    this.intField = value;
  }

    /**
     * Sets intField to the specified value.
     * Accepts a long value and converts it to int with bounds checking.
     * @param value The long value to set
     * @throws org.apache.avro.AvroRuntimeException if the value is outside the int range
     */
    public void setIntField(long value) {
        if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) {
            setIntField((int) value);
        } else {
            throw new org.apache.avro.AvroRuntimeException("Long value " + value + " cannot be cast to int");
        }
    }

  /**
   * Gets the value of the 'boxedLongField' field.
   * @return The value of the 'boxedLongField' field.
   */
  public java.lang.Long getBoxedLongField() {
    return boxedLongField;
  }


  /**
   * Sets the value of the 'boxedLongField' field.
   * @param value the value to set.
   */
  public void setBoxedLongField(java.lang.Long value) {
    this.boxedLongField = value;
  }

    /**
     * Sets boxedLongField to the specified value.
     * Accepts an Integer value and converts it to Long.
     * @param value The Integer value to set
     */
    public void setBoxedLongField(java.lang.Integer value) {
        if (value == null) {
            setBoxedLongField((java.lang.Long) null);
        } else {
            setBoxedLongField(value.longValue());
        }
    }

  /**
   * Gets the value of the 'boxedIntField' field.
   * @return The value of the 'boxedIntField' field.
   */
  public java.lang.Integer getBoxedIntField() {
    return boxedIntField;
  }


  /**
   * Sets the value of the 'boxedIntField' field.
   * @param value the value to set.
   */
  public void setBoxedIntField(java.lang.Integer value) {
    this.boxedIntField = value;
  }

    /**
     * Sets boxedIntField to the specified value.
     * Accepts a Long value and converts it to Integer with bounds checking.
     * @param value The Long value to set
     * @throws org.apache.avro.AvroRuntimeException if the value is outside the Integer range
     */
    public void setBoxedIntField(java.lang.Long value) {
        if (value == null) {
            setBoxedIntField((java.lang.Integer) null);
        } else if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) {
            setBoxedIntField(value.intValue());
        } else {
            throw new org.apache.avro.AvroRuntimeException("Long value " + value + " cannot be cast to Integer");
        }
    }

  

  @SuppressWarnings("unchecked")
  private static final org.apache.avro.io.DatumWriter<IntsAndLongs>
    WRITER$ = AvroCompatibilityHelper.newSpecificDatumWriter(SCHEMA$, MODEL$);

  public void writeExternal(java.io.ObjectOutput out)
    throws java.io.IOException {
    WRITER$.write(this, AvroCompatibilityHelper.newBinaryEncoder(out));
  }

  @SuppressWarnings("unchecked")
  private static final org.apache.avro.io.DatumReader<IntsAndLongs>
    READER$ = AvroCompatibilityHelper.newSpecificDatumReader(SCHEMA$, SCHEMA$, MODEL$);

  public void readExternal(java.io.ObjectInput in)
    throws java.io.IOException {
    READER$.read(this, AvroCompatibilityHelper.newBinaryDecoder(in));
  }

  
}

java file before change avro1_4
package under14;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;
import org.apache.avro.specific.SpecificData;


@SuppressWarnings("all")
public class IntsAndLongs extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
  public static final org.apache.avro.Schema SCHEMA$ = AvroCompatibilityHelper.parse("{\"type\":\"record\",\"name\":\"IntsAndLongs\",\"namespace\":\"under14\",\"fields\":[{\"name\":\"longField\",\"type\":\"long\"},{\"name\":\"intField\",\"type\":\"int\"},{\"name\":\"boxedLongField\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"boxedIntField\",\"type\":[\"null\",\"int\"],\"default\":null}]}");
 private static final org.apache.avro.specific.SpecificData MODEL$ = SpecificData.get();
 
  public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }

  public long longField;
  public int intField;
  public java.lang.Long boxedLongField;
  public java.lang.Integer boxedIntField;
  public org.apache.avro.Schema getSchema() { return SCHEMA$; }
  // Used by DatumWriter.  Applications should not call. 
  public java.lang.Object get(int field$) {
    switch (field$) {
    case 0: return longField;
    case 1: return intField;
    case 2: return boxedLongField;
    case 3: return boxedIntField;
    default: throw new org.apache.avro.AvroRuntimeException("Bad index");
    }
  }
  // Used by DatumReader.  Applications should not call. 
  @SuppressWarnings(value="unchecked")
  public void put(int field$, java.lang.Object value$) {
    switch (field$) {
    case 0: longField = (java.lang.Long)value$; break;
    case 1: intField = (java.lang.Integer)value$; break;
    case 2: boxedLongField = (java.lang.Long)value$; break;
    case 3: boxedIntField = (java.lang.Integer)value$; break;
    default: throw new org.apache.avro.AvroRuntimeException("Bad index");
    }
  }
}
java file after change avro1_4
package under14;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;
import org.apache.avro.specific.SpecificData;


@SuppressWarnings("all")
public class IntsAndLongs extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
  public static final org.apache.avro.Schema SCHEMA$ = AvroCompatibilityHelper.parse("{\"type\":\"record\",\"name\":\"IntsAndLongs\",\"namespace\":\"under14\",\"fields\":[{\"name\":\"longField\",\"type\":\"long\"},{\"name\":\"intField\",\"type\":\"int\"},{\"name\":\"boxedLongField\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"boxedIntField\",\"type\":[\"null\",\"int\"],\"default\":null}]}");
 private static final org.apache.avro.specific.SpecificData MODEL$ = SpecificData.get();
 
  public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }

  public long longField;
  public int intField;
  public java.lang.Long boxedLongField;
  public java.lang.Integer boxedIntField;
  public org.apache.avro.Schema getSchema() { return SCHEMA$; }
  // Used by DatumWriter.  Applications should not call. 
  public java.lang.Object get(int field$) {
    switch (field$) {
    case 0: return longField;
    case 1: return intField;
    case 2: return boxedLongField;
    case 3: return boxedIntField;
    default: throw new org.apache.avro.AvroRuntimeException("Bad index");
    }
  }
  // Used by DatumReader.  Applications should not call. 
  @SuppressWarnings(value="unchecked")
  public void put(int field$, java.lang.Object value$) {
  switch (field$) {
  case 0: if (value$ instanceof java.lang.Integer) {
      this.longField = ((java.lang.Integer)value$).longValue();
    } else {
      this.longField = (java.lang.Long)value$;
    }
    break;
  case 1: if (value$ instanceof java.lang.Long) {
      if ((java.lang.Long)value$ <= Integer.MAX_VALUE && (java.lang.Long)value$ >= Integer.MIN_VALUE) {
        this.intField = ((java.lang.Long)value$).intValue();
      } else {
        throw new org.apache.avro.AvroRuntimeException("Long value " + value$ + " cannot be cast to Integer");
      }
    } else {
      this.intField = (java.lang.Integer)value$;
    }
    break;
  case 2: if (value$ instanceof java.lang.Integer) {
      this.boxedLongField = ((java.lang.Integer)value$).longValue();
    } else {
      this.boxedLongField = (java.lang.Long)value$;
    }
    break;
  case 3: if (value$ instanceof java.lang.Long) {
      if ((java.lang.Long)value$ <= Integer.MAX_VALUE && (java.lang.Long)value$ >= Integer.MIN_VALUE) {
        this.boxedIntField = ((java.lang.Long)value$).intValue();
      } else {
        throw new org.apache.avro.AvroRuntimeException("Long value " + value$ + " cannot be cast to Integer");
      }
    } else {
      this.boxedIntField = (java.lang.Integer)value$;
    }
    break;
  default: throw new org.apache.avro.AvroRuntimeException("Bad index");
  }
}
}

java file before change with builder
package under110wbuilders;

import org.apache.avro.generic.GenericArray;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.util.Utf8;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;






public class IntsAndLongsWithBuilder extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
  private static final long serialVersionUID = -2589531418783033861L;
  public static final org.apache.avro.Schema SCHEMA$ = AvroCompatibilityHelper.parse("{\"type\":\"record\",\"name\":\"IntsAndLongsWithBuilder\",\"namespace\":\"under110wbuilders\",\"fields\":[{\"name\":\"longField\",\"type\":\"long\"},{\"name\":\"intField\",\"type\":\"int\"},{\"name\":\"boxedLongField\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"boxedIntField\",\"type\":[\"null\",\"int\"],\"default\":null}]}");
  public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }

  private static final org.apache.avro.specific.SpecificData MODEL$ = SpecificData.get();
private static final under110wbuilders.IntsAndLongsWithBuilder.Builder BUILDER_INSTANCE$ = new under110wbuilders.IntsAndLongsWithBuilder.Builder(false);


  

   public long longField;
   public int intField;
   public java.lang.Long boxedLongField;
   public java.lang.Integer boxedIntField;

  /**
   * Default constructor.  Note that this does not initialize fields
   * to their default values from the schema.  If that is desired then
   * one should use <code>newBuilder()</code>.
   */
  public IntsAndLongsWithBuilder() {}

  /**
   * All-args constructor.
   * @param longField The new value for longField
   * @param intField The new value for intField
   * @param boxedLongField The new value for boxedLongField
   * @param boxedIntField The new value for boxedIntField
   */
  public IntsAndLongsWithBuilder(java.lang.Long longField, java.lang.Integer intField, java.lang.Long boxedLongField, java.lang.Integer boxedIntField) {
    this.longField = longField;
    this.intField = intField;
    this.boxedLongField = boxedLongField;
    this.boxedIntField = boxedIntField;
  }

  public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }
  public org.apache.avro.Schema getSchema() { return SCHEMA$; }
  // Used by DatumWriter.  Applications should not call.
  public java.lang.Object get(int field$) {
    switch (field$) {
    case 0: return longField;
    case 1: return intField;
    case 2: return boxedLongField;
    case 3: return boxedIntField;
    default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
    }
  }

  // Used by DatumReader.  Applications should not call.
  @SuppressWarnings(value="unchecked")
  public void put(int field$, java.lang.Object value$) {
    switch (field$) {
    case 0: longField = (java.lang.Long)value$; break;
    case 1: intField = (java.lang.Integer)value$; break;
    case 2: boxedLongField = (java.lang.Long)value$; break;
    case 3: boxedIntField = (java.lang.Integer)value$; break;
    default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
    }
  }

  /**
   * Gets the value of the 'longField' field.
   * @return The value of the 'longField' field.
   */
  public long getLongField() {
    return longField;
  }


  /**
   * Sets the value of the 'longField' field.
   * @param value the value to set.
   */
  public void setLongField(long value) {
    this.longField = value;
  }

  /**
   * Gets the value of the 'intField' field.
   * @return The value of the 'intField' field.
   */
  public int getIntField() {
    return intField;
  }


  /**
   * Sets the value of the 'intField' field.
   * @param value the value to set.
   */
  public void setIntField(int value) {
    this.intField = value;
  }

  /**
   * Gets the value of the 'boxedLongField' field.
   * @return The value of the 'boxedLongField' field.
   */
  public java.lang.Long getBoxedLongField() {
    return boxedLongField;
  }


  /**
   * Sets the value of the 'boxedLongField' field.
   * @param value the value to set.
   */
  public void setBoxedLongField(java.lang.Long value) {
    this.boxedLongField = value;
  }

  /**
   * Gets the value of the 'boxedIntField' field.
   * @return The value of the 'boxedIntField' field.
   */
  public java.lang.Integer getBoxedIntField() {
    return boxedIntField;
  }


  /**
   * Sets the value of the 'boxedIntField' field.
   * @param value the value to set.
   */
  public void setBoxedIntField(java.lang.Integer value) {
    this.boxedIntField = value;
  }

  /**
   * Creates a new IntsAndLongsWithBuilder RecordBuilder.
   * @return A new IntsAndLongsWithBuilder RecordBuilder
   */
  public static under110wbuilders.IntsAndLongsWithBuilder.Builder newBuilder() {
    return new under110wbuilders.IntsAndLongsWithBuilder.Builder();
  }

  /**
   * Creates a new IntsAndLongsWithBuilder RecordBuilder by copying an existing Builder.
   * @param other The existing builder to copy.
   * @return A new IntsAndLongsWithBuilder RecordBuilder
   */
  public static under110wbuilders.IntsAndLongsWithBuilder.Builder newBuilder(under110wbuilders.IntsAndLongsWithBuilder.Builder other) {
    if (other == null) {
      return new under110wbuilders.IntsAndLongsWithBuilder.Builder();
    } else {
      return new under110wbuilders.IntsAndLongsWithBuilder.Builder(other);
    }
  }

  /**
   * Creates a new IntsAndLongsWithBuilder RecordBuilder by copying an existing IntsAndLongsWithBuilder instance.
   * @param other The existing instance to copy.
   * @return A new IntsAndLongsWithBuilder RecordBuilder
   */
  public static under110wbuilders.IntsAndLongsWithBuilder.Builder newBuilder(under110wbuilders.IntsAndLongsWithBuilder other) {
    if (other == null) {
      return new under110wbuilders.IntsAndLongsWithBuilder.Builder();
    } else {
      return new under110wbuilders.IntsAndLongsWithBuilder.Builder(other);
    }
  }

  /**
   * RecordBuilder for IntsAndLongsWithBuilder instances.
   */
  
  public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<IntsAndLongsWithBuilder>
    implements org.apache.avro.data.RecordBuilder<IntsAndLongsWithBuilder> {
private Builder(boolean unused) { super(SCHEMA$); }

    private long longField;
    private int intField;
    private java.lang.Long boxedLongField;
    private java.lang.Integer boxedIntField;

    /** Creates a new Builder */
    private Builder() {
this(BUILDER_INSTANCE$);
    }

    /**
     * Creates a Builder by copying an existing Builder.
     * @param other The existing Builder to copy.
     */
    private Builder(under110wbuilders.IntsAndLongsWithBuilder.Builder other) {
      super(other);
      if (isValidValue(fields()[0], other.longField)) {
        this.longField = data().deepCopy(fields()[0].schema(), other.longField);
        fieldSetFlags()[0] = other.fieldSetFlags()[0];
      }
      if (isValidValue(fields()[1], other.intField)) {
        this.intField = data().deepCopy(fields()[1].schema(), other.intField);
        fieldSetFlags()[1] = other.fieldSetFlags()[1];
      }
      if (isValidValue(fields()[2], other.boxedLongField)) {
        this.boxedLongField = data().deepCopy(fields()[2].schema(), other.boxedLongField);
        fieldSetFlags()[2] = other.fieldSetFlags()[2];
      }
      if (isValidValue(fields()[3], other.boxedIntField)) {
        this.boxedIntField = data().deepCopy(fields()[3].schema(), other.boxedIntField);
        fieldSetFlags()[3] = other.fieldSetFlags()[3];
      }
    }

    /**
     * Creates a Builder by copying an existing IntsAndLongsWithBuilder instance
     * @param other The existing instance to copy.
     */
    private Builder(under110wbuilders.IntsAndLongsWithBuilder other) {
this(BUILDER_INSTANCE$);
      if (isValidValue(fields()[0], other.longField)) {
        this.longField = data().deepCopy(fields()[0].schema(), other.longField);
        fieldSetFlags()[0] = true;
      }
      if (isValidValue(fields()[1], other.intField)) {
        this.intField = data().deepCopy(fields()[1].schema(), other.intField);
        fieldSetFlags()[1] = true;
      }
      if (isValidValue(fields()[2], other.boxedLongField)) {
        this.boxedLongField = data().deepCopy(fields()[2].schema(), other.boxedLongField);
        fieldSetFlags()[2] = true;
      }
      if (isValidValue(fields()[3], other.boxedIntField)) {
        this.boxedIntField = data().deepCopy(fields()[3].schema(), other.boxedIntField);
        fieldSetFlags()[3] = true;
      }
    }

    /**
      * Gets the value of the 'longField' field.
      * @return The value.
      */
    public long getLongField() {
      return longField;
    }


    /**
      * Sets the value of the 'longField' field.
      * @param value The value of 'longField'.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder setLongField(long value) {
      validate(fields()[0], value);
      this.longField = value;
      fieldSetFlags()[0] = true;
      return this;
    }

    /**
      * Checks whether the 'longField' field has been set.
      * @return True if the 'longField' field has been set, false otherwise.
      */
    public boolean hasLongField() {
      return fieldSetFlags()[0];
    }


    /**
      * Clears the value of the 'longField' field.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder clearLongField() {
      fieldSetFlags()[0] = false;
      return this;
    }

    /**
      * Gets the value of the 'intField' field.
      * @return The value.
      */
    public int getIntField() {
      return intField;
    }


    /**
      * Sets the value of the 'intField' field.
      * @param value The value of 'intField'.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder setIntField(int value) {
      validate(fields()[1], value);
      this.intField = value;
      fieldSetFlags()[1] = true;
      return this;
    }

    /**
      * Checks whether the 'intField' field has been set.
      * @return True if the 'intField' field has been set, false otherwise.
      */
    public boolean hasIntField() {
      return fieldSetFlags()[1];
    }


    /**
      * Clears the value of the 'intField' field.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder clearIntField() {
      fieldSetFlags()[1] = false;
      return this;
    }

    /**
      * Gets the value of the 'boxedLongField' field.
      * @return The value.
      */
    public java.lang.Long getBoxedLongField() {
      return boxedLongField;
    }


    /**
      * Sets the value of the 'boxedLongField' field.
      * @param value The value of 'boxedLongField'.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder setBoxedLongField(java.lang.Long value) {
      validate(fields()[2], value);
      this.boxedLongField = value;
      fieldSetFlags()[2] = true;
      return this;
    }

    /**
      * Checks whether the 'boxedLongField' field has been set.
      * @return True if the 'boxedLongField' field has been set, false otherwise.
      */
    public boolean hasBoxedLongField() {
      return fieldSetFlags()[2];
    }


    /**
      * Clears the value of the 'boxedLongField' field.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder clearBoxedLongField() {
      boxedLongField = null;
      fieldSetFlags()[2] = false;
      return this;
    }

    /**
      * Gets the value of the 'boxedIntField' field.
      * @return The value.
      */
    public java.lang.Integer getBoxedIntField() {
      return boxedIntField;
    }


    /**
      * Sets the value of the 'boxedIntField' field.
      * @param value The value of 'boxedIntField'.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder setBoxedIntField(java.lang.Integer value) {
      validate(fields()[3], value);
      this.boxedIntField = value;
      fieldSetFlags()[3] = true;
      return this;
    }

    /**
      * Checks whether the 'boxedIntField' field has been set.
      * @return True if the 'boxedIntField' field has been set, false otherwise.
      */
    public boolean hasBoxedIntField() {
      return fieldSetFlags()[3];
    }


    /**
      * Clears the value of the 'boxedIntField' field.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder clearBoxedIntField() {
      boxedIntField = null;
      fieldSetFlags()[3] = false;
      return this;
    }

    @Override
    @SuppressWarnings("unchecked")
    public IntsAndLongsWithBuilder build() {
      try {
        IntsAndLongsWithBuilder record = new IntsAndLongsWithBuilder();
        record.longField = fieldSetFlags()[0] ? this.longField : (java.lang.Long) defaultValue(fields()[0]);
        record.intField = fieldSetFlags()[1] ? this.intField : (java.lang.Integer) defaultValue(fields()[1]);
        record.boxedLongField = fieldSetFlags()[2] ? this.boxedLongField : (java.lang.Long) defaultValue(fields()[2]);
        record.boxedIntField = fieldSetFlags()[3] ? this.boxedIntField : (java.lang.Integer) defaultValue(fields()[3]);
        return record;
      } catch (java.lang.Exception e) {
        throw e instanceof org.apache.avro.AvroRuntimeException ? (org.apache.avro.AvroRuntimeException) e : new org.apache.avro.AvroRuntimeException(e);
      }
    }
  }

  @SuppressWarnings("unchecked")
  private static final org.apache.avro.io.DatumWriter<IntsAndLongsWithBuilder>
    WRITER$ = AvroCompatibilityHelper.newSpecificDatumWriter(SCHEMA$, MODEL$);

  public void writeExternal(java.io.ObjectOutput out)
    throws java.io.IOException {
    WRITER$.write(this, AvroCompatibilityHelper.newBinaryEncoder(out));
  }

  @SuppressWarnings("unchecked")
  private static final org.apache.avro.io.DatumReader<IntsAndLongsWithBuilder>
    READER$ = AvroCompatibilityHelper.newSpecificDatumReader(SCHEMA$, SCHEMA$, MODEL$);

  public void readExternal(java.io.ObjectInput in)
    throws java.io.IOException {
    READER$.read(this, AvroCompatibilityHelper.newBinaryDecoder(in));
  }

  
}
java file after change with builder
package under110wbuilders;

import org.apache.avro.generic.GenericArray;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.util.Utf8;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;






public class IntsAndLongsWithBuilder extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
  private static final long serialVersionUID = -2589531418783033861L;
  public static final org.apache.avro.Schema SCHEMA$ = AvroCompatibilityHelper.parse("{\"type\":\"record\",\"name\":\"IntsAndLongsWithBuilder\",\"namespace\":\"under110wbuilders\",\"fields\":[{\"name\":\"longField\",\"type\":\"long\"},{\"name\":\"intField\",\"type\":\"int\"},{\"name\":\"boxedLongField\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"boxedIntField\",\"type\":[\"null\",\"int\"],\"default\":null}]}");
  public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }

  private static final org.apache.avro.specific.SpecificData MODEL$ = SpecificData.get();
private static final under110wbuilders.IntsAndLongsWithBuilder.Builder BUILDER_INSTANCE$ = new under110wbuilders.IntsAndLongsWithBuilder.Builder(false);


  

   public long longField;
   public int intField;
   public java.lang.Long boxedLongField;
   public java.lang.Integer boxedIntField;

  /**
   * Default constructor.  Note that this does not initialize fields
   * to their default values from the schema.  If that is desired then
   * one should use <code>newBuilder()</code>.
   */
  public IntsAndLongsWithBuilder() {}

  /**
   * All-args constructor.
   * @param longField The new value for longField
   * @param intField The new value for intField
   * @param boxedLongField The new value for boxedLongField
   * @param boxedIntField The new value for boxedIntField
   */
  public IntsAndLongsWithBuilder(java.lang.Long longField, java.lang.Integer intField, java.lang.Long boxedLongField, java.lang.Integer boxedIntField) {
    this.longField = longField;
    this.intField = intField;
    this.boxedLongField = boxedLongField;
    this.boxedIntField = boxedIntField;
  }

  /**
   * All-args constructor with flexible numeric type conversion.
   * Allows Integer parameters for Long fields and Long parameters for Integer fields.
   * @param longField The new value for longField
   * @param intField The new value for intField
   * @param boxedLongField The new value for boxedLongField
   * @param boxedIntField The new value for boxedIntField
   */
  public IntsAndLongsWithBuilder(java.lang.Integer longField, java.lang.Long intField, java.lang.Integer boxedLongField, java.lang.Long boxedIntField) {
    this.longField = longField == null ? 0L : longField.longValue();
    if (intField == null) {
      this.intField = 0;
    } else if (intField <= Integer.MAX_VALUE && intField >= Integer.MIN_VALUE) {
      this.intField = intField.intValue();
    } else {
      throw new org.apache.avro.AvroRuntimeException("Long value " + intField + " cannot be cast to int");
    }
    if (boxedLongField == null) {
      this.boxedLongField = null;
    } else {
      this.boxedLongField = boxedLongField.longValue();
    }
    if (boxedIntField == null) {
      this.boxedIntField = null;
    } else if (boxedIntField <= Integer.MAX_VALUE && boxedIntField >= Integer.MIN_VALUE) {
      this.boxedIntField = boxedIntField.intValue();
    } else {
      throw new org.apache.avro.AvroRuntimeException("Long value " + boxedIntField + " cannot be cast to Integer");
    }
  }

  public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }
  public org.apache.avro.Schema getSchema() { return SCHEMA$; }
  // Used by DatumWriter.  Applications should not call.
  public java.lang.Object get(int field$) {
    switch (field$) {
    case 0: return longField;
    case 1: return intField;
    case 2: return boxedLongField;
    case 3: return boxedIntField;
    default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
    }
  }

  // Used by DatumReader.  Applications should not call.
  @SuppressWarnings(value="unchecked")
  public void put(int field$, java.lang.Object value$) {
  switch (field$) {
  case 0: if (value$ instanceof java.lang.Integer) {
      this.longField = ((java.lang.Integer)value$).longValue();
    } else {
      this.longField = (java.lang.Long)value$;
    }
    break;
  case 1: if (value$ instanceof java.lang.Long) {
      if ((java.lang.Long)value$ <= Integer.MAX_VALUE && (java.lang.Long)value$ >= Integer.MIN_VALUE) {
        this.intField = ((java.lang.Long)value$).intValue();
      } else {
        throw new org.apache.avro.AvroRuntimeException("Long value " + value$ + " cannot be cast to Integer");
      }
    } else {
      this.intField = (java.lang.Integer)value$;
    }
    break;
  case 2: if (value$ instanceof java.lang.Integer) {
      this.boxedLongField = ((java.lang.Integer)value$).longValue();
    } else {
      this.boxedLongField = (java.lang.Long)value$;
    }
    break;
  case 3: if (value$ instanceof java.lang.Long) {
      if ((java.lang.Long)value$ <= Integer.MAX_VALUE && (java.lang.Long)value$ >= Integer.MIN_VALUE) {
        this.boxedIntField = ((java.lang.Long)value$).intValue();
      } else {
        throw new org.apache.avro.AvroRuntimeException("Long value " + value$ + " cannot be cast to Integer");
      }
    } else {
      this.boxedIntField = (java.lang.Integer)value$;
    }
    break;
  default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
  }
}

  /**
   * Gets the value of the 'longField' field.
   * @return The value of the 'longField' field.
   */
  public long getLongField() {
    return longField;
  }


  /**
   * Sets the value of the 'longField' field.
   * @param value the value to set.
   */
  public void setLongField(long value) {
    this.longField = value;
  }

    /**
     * Sets longField to the specified value.
     * Accepts an int value and converts it to long.
     * @param value The int value to set
     */
    public void setLongField(int value) {
        setLongField((long) value);
    }

  /**
   * Gets the value of the 'intField' field.
   * @return The value of the 'intField' field.
   */
  public int getIntField() {
    return intField;
  }


  /**
   * Sets the value of the 'intField' field.
   * @param value the value to set.
   */
  public void setIntField(int value) {
    this.intField = value;
  }

    /**
     * Sets intField to the specified value.
     * Accepts a long value and converts it to int with bounds checking.
     * @param value The long value to set
     * @throws org.apache.avro.AvroRuntimeException if the value is outside the int range
     */
    public void setIntField(long value) {
        if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) {
            setIntField((int) value);
        } else {
            throw new org.apache.avro.AvroRuntimeException("Long value " + value + " cannot be cast to int");
        }
    }

  /**
   * Gets the value of the 'boxedLongField' field.
   * @return The value of the 'boxedLongField' field.
   */
  public java.lang.Long getBoxedLongField() {
    return boxedLongField;
  }


  /**
   * Sets the value of the 'boxedLongField' field.
   * @param value the value to set.
   */
  public void setBoxedLongField(java.lang.Long value) {
    this.boxedLongField = value;
  }

    /**
     * Sets boxedLongField to the specified value.
     * Accepts an Integer value and converts it to Long.
     * @param value The Integer value to set
     */
    public void setBoxedLongField(java.lang.Integer value) {
        if (value == null) {
            setBoxedLongField((java.lang.Long) null);
        } else {
            setBoxedLongField(value.longValue());
        }
    }

  /**
   * Gets the value of the 'boxedIntField' field.
   * @return The value of the 'boxedIntField' field.
   */
  public java.lang.Integer getBoxedIntField() {
    return boxedIntField;
  }


  /**
   * Sets the value of the 'boxedIntField' field.
   * @param value the value to set.
   */
  public void setBoxedIntField(java.lang.Integer value) {
    this.boxedIntField = value;
  }

    /**
     * Sets boxedIntField to the specified value.
     * Accepts a Long value and converts it to Integer with bounds checking.
     * @param value The Long value to set
     * @throws org.apache.avro.AvroRuntimeException if the value is outside the Integer range
     */
    public void setBoxedIntField(java.lang.Long value) {
        if (value == null) {
            setBoxedIntField((java.lang.Integer) null);
        } else if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) {
            setBoxedIntField(value.intValue());
        } else {
            throw new org.apache.avro.AvroRuntimeException("Long value " + value + " cannot be cast to Integer");
        }
    }

  /**
   * Creates a new IntsAndLongsWithBuilder RecordBuilder.
   * @return A new IntsAndLongsWithBuilder RecordBuilder
   */
  public static under110wbuilders.IntsAndLongsWithBuilder.Builder newBuilder() {
    return new under110wbuilders.IntsAndLongsWithBuilder.Builder();
  }

  /**
   * Creates a new IntsAndLongsWithBuilder RecordBuilder by copying an existing Builder.
   * @param other The existing builder to copy.
   * @return A new IntsAndLongsWithBuilder RecordBuilder
   */
  public static under110wbuilders.IntsAndLongsWithBuilder.Builder newBuilder(under110wbuilders.IntsAndLongsWithBuilder.Builder other) {
    if (other == null) {
      return new under110wbuilders.IntsAndLongsWithBuilder.Builder();
    } else {
      return new under110wbuilders.IntsAndLongsWithBuilder.Builder(other);
    }
  }

  /**
   * Creates a new IntsAndLongsWithBuilder RecordBuilder by copying an existing IntsAndLongsWithBuilder instance.
   * @param other The existing instance to copy.
   * @return A new IntsAndLongsWithBuilder RecordBuilder
   */
  public static under110wbuilders.IntsAndLongsWithBuilder.Builder newBuilder(under110wbuilders.IntsAndLongsWithBuilder other) {
    if (other == null) {
      return new under110wbuilders.IntsAndLongsWithBuilder.Builder();
    } else {
      return new under110wbuilders.IntsAndLongsWithBuilder.Builder(other);
    }
  }

  /**
   * RecordBuilder for IntsAndLongsWithBuilder instances.
   */
  
  public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<IntsAndLongsWithBuilder>
    implements org.apache.avro.data.RecordBuilder<IntsAndLongsWithBuilder> {
private Builder(boolean unused) { super(SCHEMA$); }

    private long longField;
    private int intField;
    private java.lang.Long boxedLongField;
    private java.lang.Integer boxedIntField;

    /** Creates a new Builder */
    private Builder() {
this(BUILDER_INSTANCE$);
    }

    /**
     * Creates a Builder by copying an existing Builder.
     * @param other The existing Builder to copy.
     */
    private Builder(under110wbuilders.IntsAndLongsWithBuilder.Builder other) {
      super(other);
      if (isValidValue(fields()[0], other.longField)) {
        this.longField = data().deepCopy(fields()[0].schema(), other.longField);
        fieldSetFlags()[0] = other.fieldSetFlags()[0];
      }
      if (isValidValue(fields()[1], other.intField)) {
        this.intField = data().deepCopy(fields()[1].schema(), other.intField);
        fieldSetFlags()[1] = other.fieldSetFlags()[1];
      }
      if (isValidValue(fields()[2], other.boxedLongField)) {
        this.boxedLongField = data().deepCopy(fields()[2].schema(), other.boxedLongField);
        fieldSetFlags()[2] = other.fieldSetFlags()[2];
      }
      if (isValidValue(fields()[3], other.boxedIntField)) {
        this.boxedIntField = data().deepCopy(fields()[3].schema(), other.boxedIntField);
        fieldSetFlags()[3] = other.fieldSetFlags()[3];
      }
    }

    /**
     * Creates a Builder by copying an existing IntsAndLongsWithBuilder instance
     * @param other The existing instance to copy.
     */
    private Builder(under110wbuilders.IntsAndLongsWithBuilder other) {
this(BUILDER_INSTANCE$);
      if (isValidValue(fields()[0], other.longField)) {
        this.longField = data().deepCopy(fields()[0].schema(), other.longField);
        fieldSetFlags()[0] = true;
      }
      if (isValidValue(fields()[1], other.intField)) {
        this.intField = data().deepCopy(fields()[1].schema(), other.intField);
        fieldSetFlags()[1] = true;
      }
      if (isValidValue(fields()[2], other.boxedLongField)) {
        this.boxedLongField = data().deepCopy(fields()[2].schema(), other.boxedLongField);
        fieldSetFlags()[2] = true;
      }
      if (isValidValue(fields()[3], other.boxedIntField)) {
        this.boxedIntField = data().deepCopy(fields()[3].schema(), other.boxedIntField);
        fieldSetFlags()[3] = true;
      }
    }

    /**
      * Gets the value of the 'longField' field.
      * @return The value.
      */
    public long getLongField() {
      return longField;
    }


    /**
      * Sets the value of the 'longField' field.
      * @param value The value of 'longField'.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder setLongField(long value) {
      validate(fields()[0], value);
      this.longField = value;
      fieldSetFlags()[0] = true;
      return this;
    }

    /**
     * Sets value to the specified value.
     * Accepts an int value and converts it to long.
     * @param value The int value to set
     * @return This builder
     */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder setLongField(int value) {
        return setLongField((long) value);
    }

    /**
      * Checks whether the 'longField' field has been set.
      * @return True if the 'longField' field has been set, false otherwise.
      */
    public boolean hasLongField() {
      return fieldSetFlags()[0];
    }


    /**
      * Clears the value of the 'longField' field.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder clearLongField() {
      fieldSetFlags()[0] = false;
      return this;
    }

    /**
      * Gets the value of the 'intField' field.
      * @return The value.
      */
    public int getIntField() {
      return intField;
    }


    /**
      * Sets the value of the 'intField' field.
      * @param value The value of 'intField'.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder setIntField(int value) {
      validate(fields()[1], value);
      this.intField = value;
      fieldSetFlags()[1] = true;
      return this;
    }

    /**
     * Sets value to the specified value.
     * Accepts a long value and converts it to int with bounds checking.
     * @param value The long value to set
     * @return This builder
     * @throws org.apache.avro.AvroRuntimeException if the value is outside the int range
     */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder setIntField(long value) {
        if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) {
            return setIntField((int) value);
        } else {
            throw new org.apache.avro.AvroRuntimeException("Long value " + value + " cannot be cast to int");
        }
    }

    /**
      * Checks whether the 'intField' field has been set.
      * @return True if the 'intField' field has been set, false otherwise.
      */
    public boolean hasIntField() {
      return fieldSetFlags()[1];
    }


    /**
      * Clears the value of the 'intField' field.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder clearIntField() {
      fieldSetFlags()[1] = false;
      return this;
    }

    /**
      * Gets the value of the 'boxedLongField' field.
      * @return The value.
      */
    public java.lang.Long getBoxedLongField() {
      return boxedLongField;
    }


    /**
      * Sets the value of the 'boxedLongField' field.
      * @param value The value of 'boxedLongField'.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder setBoxedLongField(java.lang.Long value) {
      validate(fields()[2], value);
      this.boxedLongField = value;
      fieldSetFlags()[2] = true;
      return this;
    }

    /**
     * Sets value to the specified value.
     * Accepts an Integer value and converts it to Long.
     * @param value The Integer value to set
     * @return This builder
     */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder setBoxedLongField(java.lang.Integer value) {
        if (value == null) {
            return setBoxedLongField((java.lang.Long) null);
        } else {
            return setBoxedLongField(value.longValue());
        }
    }

    /**
      * Checks whether the 'boxedLongField' field has been set.
      * @return True if the 'boxedLongField' field has been set, false otherwise.
      */
    public boolean hasBoxedLongField() {
      return fieldSetFlags()[2];
    }


    /**
      * Clears the value of the 'boxedLongField' field.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder clearBoxedLongField() {
      boxedLongField = null;
      fieldSetFlags()[2] = false;
      return this;
    }

    /**
      * Gets the value of the 'boxedIntField' field.
      * @return The value.
      */
    public java.lang.Integer getBoxedIntField() {
      return boxedIntField;
    }


    /**
      * Sets the value of the 'boxedIntField' field.
      * @param value The value of 'boxedIntField'.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder setBoxedIntField(java.lang.Integer value) {
      validate(fields()[3], value);
      this.boxedIntField = value;
      fieldSetFlags()[3] = true;
      return this;
    }

    /**
     * Sets value to the specified value.
     * Accepts a Long value and converts it to Integer with bounds checking.
     * @param value The Long value to set
     * @return This builder
     * @throws org.apache.avro.AvroRuntimeException if the value is outside the Integer range
     */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder setBoxedIntField(java.lang.Long value) {
        if (value == null) {
            return setBoxedIntField((java.lang.Integer) null);
        } else if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) {
            return setBoxedIntField(value.intValue());
        } else {
            throw new org.apache.avro.AvroRuntimeException("Long value " + value + " cannot be cast to Integer");
        }
    }

    /**
      * Checks whether the 'boxedIntField' field has been set.
      * @return True if the 'boxedIntField' field has been set, false otherwise.
      */
    public boolean hasBoxedIntField() {
      return fieldSetFlags()[3];
    }


    /**
      * Clears the value of the 'boxedIntField' field.
      * @return This builder.
      */
    public under110wbuilders.IntsAndLongsWithBuilder.Builder clearBoxedIntField() {
      boxedIntField = null;
      fieldSetFlags()[3] = false;
      return this;
    }

    @Override
    @SuppressWarnings("unchecked")
    public IntsAndLongsWithBuilder build() {
      try {
        IntsAndLongsWithBuilder record = new IntsAndLongsWithBuilder();
        record.longField = fieldSetFlags()[0] ? this.longField : (java.lang.Long) defaultValue(fields()[0]);
        record.intField = fieldSetFlags()[1] ? this.intField : (java.lang.Integer) defaultValue(fields()[1]);
        record.boxedLongField = fieldSetFlags()[2] ? this.boxedLongField : (java.lang.Long) defaultValue(fields()[2]);
        record.boxedIntField = fieldSetFlags()[3] ? this.boxedIntField : (java.lang.Integer) defaultValue(fields()[3]);
        return record;
      } catch (java.lang.Exception e) {
        throw e instanceof org.apache.avro.AvroRuntimeException ? (org.apache.avro.AvroRuntimeException) e : new org.apache.avro.AvroRuntimeException(e);
      }
    }
  }

  @SuppressWarnings("unchecked")
  private static final org.apache.avro.io.DatumWriter<IntsAndLongsWithBuilder>
    WRITER$ = AvroCompatibilityHelper.newSpecificDatumWriter(SCHEMA$, MODEL$);

  public void writeExternal(java.io.ObjectOutput out)
    throws java.io.IOException {
    WRITER$.write(this, AvroCompatibilityHelper.newBinaryEncoder(out));
  }

  @SuppressWarnings("unchecked")
  private static final org.apache.avro.io.DatumReader<IntsAndLongsWithBuilder>
    READER$ = AvroCompatibilityHelper.newSpecificDatumReader(SCHEMA$, SCHEMA$, MODEL$);

  public void readExternal(java.io.ObjectInput in)
    throws java.io.IOException {
    READER$.read(this, AvroCompatibilityHelper.newBinaryDecoder(in));
  }

  
}

@li-enguyen li-enguyen marked this pull request as ready for review June 3, 2025 18:34
} else if ("long".equals(fieldType)) {
overloadSignature = "public void " + methodName + "(int ";
} else if (JAVA_LANG_INTEGER.equals(fieldType)) {
overloadSignature = "public void " + methodName + "(java.lang.Long ";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried
public void setMemberId(java.lang.Integer i)
public void setMemberId(java.lang.Long l)

And the MP has
int memberId=5;
setMemberId(memberId);
Will the right method be called or would there be a runtime error because two methods can support the value 5

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a quick unit test for this: In this case, the setMemberId(java.lang.Integer i) method will be called, since the memberId is int. int will not get auto boxed into a Long in java

@li-enguyen li-enguyen changed the title [WIP] Updating CodeTransformations to enable int/long setters/puts conversions Updating CodeTransformations to enable int/long setters/puts conversions Jun 17, 2025
@@ -0,0 +1,267 @@
/*
* Copyright 2022 LinkedIn Corp.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2025?

@sandaar
Copy link
Contributor

sandaar commented Jul 15, 2025

This PR can be closed as #583 replaces it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants