/**
 * Autogenerated by Avro
 *
 * DO NOT EDIT DIRECTLY
 */
package schemaregistry;

import org.apache.avro.generic.GenericArray;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.util.Utf8;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;

@org.apache.avro.specific.AvroGenerated
public class RideRecordNoneCompatible extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
  private static final long serialVersionUID = -4618980179396772493L;


  public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"RideRecordNoneCompatible\",\"namespace\":\"schemaregistry\",\"fields\":[{\"name\":\"vendorId\",\"type\":\"int\"},{\"name\":\"passenger_count\",\"type\":\"int\"},{\"name\":\"trip_distance\",\"type\":\"double\"}]}");
  public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }

  private static final SpecificData MODEL$ = new SpecificData();

  private static final BinaryMessageEncoder<RideRecordNoneCompatible> ENCODER =
      new BinaryMessageEncoder<>(MODEL$, SCHEMA$);

  private static final BinaryMessageDecoder<RideRecordNoneCompatible> DECODER =
      new BinaryMessageDecoder<>(MODEL$, SCHEMA$);

  /**
   * Return the BinaryMessageEncoder instance used by this class.
   * @return the message encoder used by this class
   */
  public static BinaryMessageEncoder<RideRecordNoneCompatible> getEncoder() {
    return ENCODER;
  }

  /**
   * Return the BinaryMessageDecoder instance used by this class.
   * @return the message decoder used by this class
   */
  public static BinaryMessageDecoder<RideRecordNoneCompatible> getDecoder() {
    return DECODER;
  }

  /**
   * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
   * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
   * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore
   */
  public static BinaryMessageDecoder<RideRecordNoneCompatible> createDecoder(SchemaStore resolver) {
    return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver);
  }

  /**
   * Serializes this RideRecordNoneCompatible to a ByteBuffer.
   * @return a buffer holding the serialized data for this instance
   * @throws java.io.IOException if this instance could not be serialized
   */
  public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
    return ENCODER.encode(this);
  }

  /**
   * Deserializes a RideRecordNoneCompatible from a ByteBuffer.
   * @param b a byte buffer holding serialized data for an instance of this class
   * @return a RideRecordNoneCompatible instance decoded from the given buffer
   * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class
   */
  public static RideRecordNoneCompatible fromByteBuffer(
      java.nio.ByteBuffer b) throws java.io.IOException {
    return DECODER.decode(b);
  }

  private int vendorId;
  private int passenger_count;
  private double trip_distance;

  /**
   * 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 RideRecordNoneCompatible() {}

  /**
   * All-args constructor.
   * @param vendorId The new value for vendorId
   * @param passenger_count The new value for passenger_count
   * @param trip_distance The new value for trip_distance
   */
  public RideRecordNoneCompatible(java.lang.Integer vendorId, java.lang.Integer passenger_count, java.lang.Double trip_distance) {
    this.vendorId = vendorId;
    this.passenger_count = passenger_count;
    this.trip_distance = trip_distance;
  }

  @Override
  public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }

  @Override
  public org.apache.avro.Schema getSchema() { return SCHEMA$; }

  // Used by DatumWriter.  Applications should not call.
  @Override
  public java.lang.Object get(int field$) {
    switch (field$) {
    case 0: return vendorId;
    case 1: return passenger_count;
    case 2: return trip_distance;
    default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
    }
  }

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

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


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

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


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

  /**
   * Gets the value of the 'trip_distance' field.
   * @return The value of the 'trip_distance' field.
   */
  public double getTripDistance() {
    return trip_distance;
  }


  /**
   * Sets the value of the 'trip_distance' field.
   * @param value the value to set.
   */
  public void setTripDistance(double value) {
    this.trip_distance = value;
  }

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

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

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

  /**
   * RecordBuilder for RideRecordNoneCompatible instances.
   */
  @org.apache.avro.specific.AvroGenerated
  public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<RideRecordNoneCompatible>
    implements org.apache.avro.data.RecordBuilder<RideRecordNoneCompatible> {

    private int vendorId;
    private int passenger_count;
    private double trip_distance;

    /** Creates a new Builder */
    private Builder() {
      super(SCHEMA$, MODEL$);
    }

    /**
     * Creates a Builder by copying an existing Builder.
     * @param other The existing Builder to copy.
     */
    private Builder(schemaregistry.RideRecordNoneCompatible.Builder other) {
      super(other);
      if (isValidValue(fields()[0], other.vendorId)) {
        this.vendorId = data().deepCopy(fields()[0].schema(), other.vendorId);
        fieldSetFlags()[0] = other.fieldSetFlags()[0];
      }
      if (isValidValue(fields()[1], other.passenger_count)) {
        this.passenger_count = data().deepCopy(fields()[1].schema(), other.passenger_count);
        fieldSetFlags()[1] = other.fieldSetFlags()[1];
      }
      if (isValidValue(fields()[2], other.trip_distance)) {
        this.trip_distance = data().deepCopy(fields()[2].schema(), other.trip_distance);
        fieldSetFlags()[2] = other.fieldSetFlags()[2];
      }
    }

    /**
     * Creates a Builder by copying an existing RideRecordNoneCompatible instance
     * @param other The existing instance to copy.
     */
    private Builder(schemaregistry.RideRecordNoneCompatible other) {
      super(SCHEMA$, MODEL$);
      if (isValidValue(fields()[0], other.vendorId)) {
        this.vendorId = data().deepCopy(fields()[0].schema(), other.vendorId);
        fieldSetFlags()[0] = true;
      }
      if (isValidValue(fields()[1], other.passenger_count)) {
        this.passenger_count = data().deepCopy(fields()[1].schema(), other.passenger_count);
        fieldSetFlags()[1] = true;
      }
      if (isValidValue(fields()[2], other.trip_distance)) {
        this.trip_distance = data().deepCopy(fields()[2].schema(), other.trip_distance);
        fieldSetFlags()[2] = true;
      }
    }

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


    /**
      * Sets the value of the 'vendorId' field.
      * @param value The value of 'vendorId'.
      * @return This builder.
      */
    public schemaregistry.RideRecordNoneCompatible.Builder setVendorId(int value) {
      validate(fields()[0], value);
      this.vendorId = value;
      fieldSetFlags()[0] = true;
      return this;
    }

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


    /**
      * Clears the value of the 'vendorId' field.
      * @return This builder.
      */
    public schemaregistry.RideRecordNoneCompatible.Builder clearVendorId() {
      fieldSetFlags()[0] = false;
      return this;
    }

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


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

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


    /**
      * Clears the value of the 'passenger_count' field.
      * @return This builder.
      */
    public schemaregistry.RideRecordNoneCompatible.Builder clearPassengerCount() {
      fieldSetFlags()[1] = false;
      return this;
    }

    /**
      * Gets the value of the 'trip_distance' field.
      * @return The value.
      */
    public double getTripDistance() {
      return trip_distance;
    }


    /**
      * Sets the value of the 'trip_distance' field.
      * @param value The value of 'trip_distance'.
      * @return This builder.
      */
    public schemaregistry.RideRecordNoneCompatible.Builder setTripDistance(double value) {
      validate(fields()[2], value);
      this.trip_distance = value;
      fieldSetFlags()[2] = true;
      return this;
    }

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


    /**
      * Clears the value of the 'trip_distance' field.
      * @return This builder.
      */
    public schemaregistry.RideRecordNoneCompatible.Builder clearTripDistance() {
      fieldSetFlags()[2] = false;
      return this;
    }

    @Override
    @SuppressWarnings("unchecked")
    public RideRecordNoneCompatible build() {
      try {
        RideRecordNoneCompatible record = new RideRecordNoneCompatible();
        record.vendorId = fieldSetFlags()[0] ? this.vendorId : (java.lang.Integer) defaultValue(fields()[0]);
        record.passenger_count = fieldSetFlags()[1] ? this.passenger_count : (java.lang.Integer) defaultValue(fields()[1]);
        record.trip_distance = fieldSetFlags()[2] ? this.trip_distance : (java.lang.Double) defaultValue(fields()[2]);
        return record;
      } catch (org.apache.avro.AvroMissingFieldException e) {
        throw e;
      } catch (java.lang.Exception e) {
        throw new org.apache.avro.AvroRuntimeException(e);
      }
    }
  }

  @SuppressWarnings("unchecked")
  private static final org.apache.avro.io.DatumWriter<RideRecordNoneCompatible>
    WRITER$ = (org.apache.avro.io.DatumWriter<RideRecordNoneCompatible>)MODEL$.createDatumWriter(SCHEMA$);

  @Override public void writeExternal(java.io.ObjectOutput out)
    throws java.io.IOException {
    WRITER$.write(this, SpecificData.getEncoder(out));
  }

  @SuppressWarnings("unchecked")
  private static final org.apache.avro.io.DatumReader<RideRecordNoneCompatible>
    READER$ = (org.apache.avro.io.DatumReader<RideRecordNoneCompatible>)MODEL$.createDatumReader(SCHEMA$);

  @Override public void readExternal(java.io.ObjectInput in)
    throws java.io.IOException {
    READER$.read(this, SpecificData.getDecoder(in));
  }

  @Override protected boolean hasCustomCoders() { return true; }

  @Override public void customEncode(org.apache.avro.io.Encoder out)
    throws java.io.IOException
  {
    out.writeInt(this.vendorId);

    out.writeInt(this.passenger_count);

    out.writeDouble(this.trip_distance);

  }

  @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in)
    throws java.io.IOException
  {
    org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff();
    if (fieldOrder == null) {
      this.vendorId = in.readInt();

      this.passenger_count = in.readInt();

      this.trip_distance = in.readDouble();

    } else {
      for (int i = 0; i < 3; i++) {
        switch (fieldOrder[i].pos()) {
        case 0:
          this.vendorId = in.readInt();
          break;

        case 1:
          this.passenger_count = in.readInt();
          break;

        case 2:
          this.trip_distance = in.readDouble();
          break;

        default:
          throw new java.io.IOException("Corrupt ResolvingDecoder.");
        }
      }
    }
  }
}










