/**
 * Autogenerated by Avro
 *
 * DO NOT EDIT DIRECTLY
 */
package com.hazelcast.jet.examples.files.unifiedapi.generated;

import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;

@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class AvroTrade extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
  private static final long serialVersionUID = 4511052104808752666L;
  public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"AvroTrade\",\"namespace\":\"com.hazelcast.jet.examples.files.unifiedapi.generated\",\"fields\":[{\"name\":\"time\",\"type\":\"long\"},{\"name\":\"ticker\",\"type\":\"string\"},{\"name\":\"quantity\",\"type\":\"long\"},{\"name\":\"price\",\"type\":\"long\"}]}");
  public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }

  private static SpecificData MODEL$ = new SpecificData();

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

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

  /**
   * Return the BinaryMessageDecoder instance used by this class.
   */
  public static BinaryMessageDecoder<AvroTrade> 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
   */
  public static BinaryMessageDecoder<AvroTrade> createDecoder(SchemaStore resolver) {
    return new BinaryMessageDecoder<AvroTrade>(MODEL$, SCHEMA$, resolver);
  }

  /** Serializes this AvroTrade to a ByteBuffer. */
  public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
    return ENCODER.encode(this);
  }

  /** Deserializes a AvroTrade from a ByteBuffer. */
  public static AvroTrade fromByteBuffer(
      java.nio.ByteBuffer b) throws java.io.IOException {
    return DECODER.decode(b);
  }

  @Deprecated public long time;
  @Deprecated public java.lang.CharSequence ticker;
  @Deprecated public long quantity;
  @Deprecated public long price;

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

  /**
   * All-args constructor.
   * @param time The new value for time
   * @param ticker The new value for ticker
   * @param quantity The new value for quantity
   * @param price The new value for price
   */
  public AvroTrade(java.lang.Long time, java.lang.CharSequence ticker, java.lang.Long quantity, java.lang.Long price) {
    this.time = time;
    this.ticker = ticker;
    this.quantity = quantity;
    this.price = price;
  }

  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 time;
    case 1: return ticker;
    case 2: return quantity;
    case 3: return price;
    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: time = (java.lang.Long)value$; break;
    case 1: ticker = (java.lang.CharSequence)value$; break;
    case 2: quantity = (java.lang.Long)value$; break;
    case 3: price = (java.lang.Long)value$; break;
    default: throw new org.apache.avro.AvroRuntimeException("Bad index");
    }
  }

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

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

  /**
   * Gets the value of the 'ticker' field.
   * @return The value of the 'ticker' field.
   */
  public java.lang.CharSequence getTicker() {
    return ticker;
  }

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

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

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

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

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

  /**
   * Creates a new AvroTrade RecordBuilder.
   * @return A new AvroTrade RecordBuilder
   */
  public static com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder newBuilder() {
    return new com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder();
  }

  /**
   * Creates a new AvroTrade RecordBuilder by copying an existing Builder.
   * @param other The existing builder to copy.
   * @return A new AvroTrade RecordBuilder
   */
  public static com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder newBuilder(com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder other) {
    return new com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder(other);
  }

  /**
   * Creates a new AvroTrade RecordBuilder by copying an existing AvroTrade instance.
   * @param other The existing instance to copy.
   * @return A new AvroTrade RecordBuilder
   */
  public static com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder newBuilder(com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade other) {
    return new com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder(other);
  }

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

    private long time;
    private java.lang.CharSequence ticker;
    private long quantity;
    private long price;

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

    /**
     * Creates a Builder by copying an existing Builder.
     * @param other The existing Builder to copy.
     */
    private Builder(com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder other) {
      super(other);
      if (isValidValue(fields()[0], other.time)) {
        this.time = data().deepCopy(fields()[0].schema(), other.time);
        fieldSetFlags()[0] = true;
      }
      if (isValidValue(fields()[1], other.ticker)) {
        this.ticker = data().deepCopy(fields()[1].schema(), other.ticker);
        fieldSetFlags()[1] = true;
      }
      if (isValidValue(fields()[2], other.quantity)) {
        this.quantity = data().deepCopy(fields()[2].schema(), other.quantity);
        fieldSetFlags()[2] = true;
      }
      if (isValidValue(fields()[3], other.price)) {
        this.price = data().deepCopy(fields()[3].schema(), other.price);
        fieldSetFlags()[3] = true;
      }
    }

    /**
     * Creates a Builder by copying an existing AvroTrade instance
     * @param other The existing instance to copy.
     */
    private Builder(com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade other) {
            super(SCHEMA$);
      if (isValidValue(fields()[0], other.time)) {
        this.time = data().deepCopy(fields()[0].schema(), other.time);
        fieldSetFlags()[0] = true;
      }
      if (isValidValue(fields()[1], other.ticker)) {
        this.ticker = data().deepCopy(fields()[1].schema(), other.ticker);
        fieldSetFlags()[1] = true;
      }
      if (isValidValue(fields()[2], other.quantity)) {
        this.quantity = data().deepCopy(fields()[2].schema(), other.quantity);
        fieldSetFlags()[2] = true;
      }
      if (isValidValue(fields()[3], other.price)) {
        this.price = data().deepCopy(fields()[3].schema(), other.price);
        fieldSetFlags()[3] = true;
      }
    }

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

    /**
      * Sets the value of the 'time' field.
      * @param value The value of 'time'.
      * @return This builder.
      */
    public com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder setTime(long value) {
      validate(fields()[0], value);
      this.time = value;
      fieldSetFlags()[0] = true;
      return this;
    }

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


    /**
      * Clears the value of the 'time' field.
      * @return This builder.
      */
    public com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder clearTime() {
      fieldSetFlags()[0] = false;
      return this;
    }

    /**
      * Gets the value of the 'ticker' field.
      * @return The value.
      */
    public java.lang.CharSequence getTicker() {
      return ticker;
    }

    /**
      * Sets the value of the 'ticker' field.
      * @param value The value of 'ticker'.
      * @return This builder.
      */
    public com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder setTicker(java.lang.CharSequence value) {
      validate(fields()[1], value);
      this.ticker = value;
      fieldSetFlags()[1] = true;
      return this;
    }

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


    /**
      * Clears the value of the 'ticker' field.
      * @return This builder.
      */
    public com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder clearTicker() {
      ticker = null;
      fieldSetFlags()[1] = false;
      return this;
    }

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

    /**
      * Sets the value of the 'quantity' field.
      * @param value The value of 'quantity'.
      * @return This builder.
      */
    public com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder setQuantity(long value) {
      validate(fields()[2], value);
      this.quantity = value;
      fieldSetFlags()[2] = true;
      return this;
    }

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


    /**
      * Clears the value of the 'quantity' field.
      * @return This builder.
      */
    public com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder clearQuantity() {
      fieldSetFlags()[2] = false;
      return this;
    }

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

    /**
      * Sets the value of the 'price' field.
      * @param value The value of 'price'.
      * @return This builder.
      */
    public com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder setPrice(long value) {
      validate(fields()[3], value);
      this.price = value;
      fieldSetFlags()[3] = true;
      return this;
    }

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


    /**
      * Clears the value of the 'price' field.
      * @return This builder.
      */
    public com.hazelcast.jet.examples.files.unifiedapi.generated.AvroTrade.Builder clearPrice() {
      fieldSetFlags()[3] = false;
      return this;
    }

    @Override
    @SuppressWarnings("unchecked")
    public AvroTrade build() {
      try {
        AvroTrade record = new AvroTrade();
        record.time = fieldSetFlags()[0] ? this.time : (java.lang.Long) defaultValue(fields()[0]);
        record.ticker = fieldSetFlags()[1] ? this.ticker : (java.lang.CharSequence) defaultValue(fields()[1]);
        record.quantity = fieldSetFlags()[2] ? this.quantity : (java.lang.Long) defaultValue(fields()[2]);
        record.price = fieldSetFlags()[3] ? this.price : (java.lang.Long) defaultValue(fields()[3]);
        return record;
      } catch (java.lang.Exception e) {
        throw new org.apache.avro.AvroRuntimeException(e);
      }
    }
  }

  @SuppressWarnings("unchecked")
  private static final org.apache.avro.io.DatumWriter<AvroTrade>
    WRITER$ = (org.apache.avro.io.DatumWriter<AvroTrade>)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<AvroTrade>
    READER$ = (org.apache.avro.io.DatumReader<AvroTrade>)MODEL$.createDatumReader(SCHEMA$);

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

}
