All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Energistics.Protocol.Store.Object Maven / Gradle / Ivy

The newest version!
/**
 * Autogenerated by Avro
 *
 * DO NOT EDIT DIRECTLY
 */
package Energistics.Protocol.Store;

import org.apache.avro.specific.SpecificData;

@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class Object extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
  private static final long serialVersionUID = 3889091155451682552L;
  public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Object\",\"namespace\":\"Energistics.Protocol.Store\",\"fields\":[{\"name\":\"dataObject\",\"type\":{\"type\":\"record\",\"name\":\"DataObject\",\"namespace\":\"Energistics.Datatypes.Object\",\"fields\":[{\"name\":\"resource\",\"type\":{\"type\":\"record\",\"name\":\"Resource\",\"fields\":[{\"name\":\"uri\",\"type\":\"string\"},{\"name\":\"contentType\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"channelSubscribable\",\"type\":\"boolean\"},{\"name\":\"customData\",\"type\":{\"type\":\"map\",\"values\":\"string\"}},{\"name\":\"resourceType\",\"type\":\"string\"},{\"name\":\"hasChildren\",\"type\":\"int\"},{\"name\":\"uuid\",\"type\":[\"null\",\"string\"]},{\"name\":\"lastChanged\",\"type\":\"long\"},{\"name\":\"objectNotifiable\",\"type\":\"boolean\"}],\"fullName\":\"Energistics.Datatypes.Object.Resource\",\"depends\":[]}},{\"name\":\"contentEncoding\",\"type\":\"string\"},{\"name\":\"data\",\"type\":\"bytes\"}],\"fullName\":\"Energistics.Datatypes.Object.DataObject\",\"depends\":[\"Energistics.Datatypes.Object.Resource\"]}}],\"messageType\":\"4\",\"protocol\":\"4\",\"senderRole\":\"store\",\"protocolRoles\":\"store,customer\",\"fullName\":\"Energistics.Protocol.Store.Object\",\"depends\":[\"Energistics.Datatypes.Object.DataObject\"]}");
  public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
  @Deprecated public Energistics.Datatypes.Object.DataObject dataObject;

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

  /**
   * All-args constructor.
   * @param dataObject The new value for dataObject
   */
  public Object(Energistics.Datatypes.Object.DataObject dataObject) {
    this.dataObject = dataObject;
  }

  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 dataObject;
    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: dataObject = (Energistics.Datatypes.Object.DataObject)value$; break;
    default: throw new org.apache.avro.AvroRuntimeException("Bad index");
    }
  }

  /**
   * Gets the value of the 'dataObject' field.
   * @return The value of the 'dataObject' field.
   */
  public Energistics.Datatypes.Object.DataObject getDataObject() {
    return dataObject;
  }

  /**
   * Sets the value of the 'dataObject' field.
   * @param value the value to set.
   */
  public void setDataObject(Energistics.Datatypes.Object.DataObject value) {
    this.dataObject = value;
  }

  /**
   * Creates a new Object RecordBuilder.
   * @return A new Object RecordBuilder
   */
  public static Energistics.Protocol.Store.Object.Builder newBuilder() {
    return new Energistics.Protocol.Store.Object.Builder();
  }

  /**
   * Creates a new Object RecordBuilder by copying an existing Builder.
   * @param other The existing builder to copy.
   * @return A new Object RecordBuilder
   */
  public static Energistics.Protocol.Store.Object.Builder newBuilder(Energistics.Protocol.Store.Object.Builder other) {
    return new Energistics.Protocol.Store.Object.Builder(other);
  }

  /**
   * Creates a new Object RecordBuilder by copying an existing Object instance.
   * @param other The existing instance to copy.
   * @return A new Object RecordBuilder
   */
  public static Energistics.Protocol.Store.Object.Builder newBuilder(Energistics.Protocol.Store.Object other) {
    return new Energistics.Protocol.Store.Object.Builder(other);
  }

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

    private Energistics.Datatypes.Object.DataObject dataObject;
    private Energistics.Datatypes.Object.DataObject.Builder dataObjectBuilder;

    /** 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(Energistics.Protocol.Store.Object.Builder other) {
      super(other);
      if (isValidValue(fields()[0], other.dataObject)) {
        this.dataObject = data().deepCopy(fields()[0].schema(), other.dataObject);
        fieldSetFlags()[0] = true;
      }
      if (other.hasDataObjectBuilder()) {
        this.dataObjectBuilder = Energistics.Datatypes.Object.DataObject.newBuilder(other.getDataObjectBuilder());
      }
    }

    /**
     * Creates a Builder by copying an existing Object instance
     * @param other The existing instance to copy.
     */
    private Builder(Energistics.Protocol.Store.Object other) {
            super(SCHEMA$);
      if (isValidValue(fields()[0], other.dataObject)) {
        this.dataObject = data().deepCopy(fields()[0].schema(), other.dataObject);
        fieldSetFlags()[0] = true;
      }
      this.dataObjectBuilder = null;
    }

    /**
      * Gets the value of the 'dataObject' field.
      * @return The value.
      */
    public Energistics.Datatypes.Object.DataObject getDataObject() {
      return dataObject;
    }

    /**
      * Sets the value of the 'dataObject' field.
      * @param value The value of 'dataObject'.
      * @return This builder.
      */
    public Energistics.Protocol.Store.Object.Builder setDataObject(Energistics.Datatypes.Object.DataObject value) {
      validate(fields()[0], value);
      this.dataObjectBuilder = null;
      this.dataObject = value;
      fieldSetFlags()[0] = true;
      return this;
    }

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

    /**
     * Gets the Builder instance for the 'dataObject' field and creates one if it doesn't exist yet.
     * @return This builder.
     */
    public Energistics.Datatypes.Object.DataObject.Builder getDataObjectBuilder() {
      if (dataObjectBuilder == null) {
        if (hasDataObject()) {
          setDataObjectBuilder(Energistics.Datatypes.Object.DataObject.newBuilder(dataObject));
        } else {
          setDataObjectBuilder(Energistics.Datatypes.Object.DataObject.newBuilder());
        }
      }
      return dataObjectBuilder;
    }

    /**
     * Sets the Builder instance for the 'dataObject' field
     * @param value The builder instance that must be set.
     * @return This builder.
     */
    public Energistics.Protocol.Store.Object.Builder setDataObjectBuilder(Energistics.Datatypes.Object.DataObject.Builder value) {
      clearDataObject();
      dataObjectBuilder = value;
      return this;
    }

    /**
     * Checks whether the 'dataObject' field has an active Builder instance
     * @return True if the 'dataObject' field has an active Builder instance
     */
    public boolean hasDataObjectBuilder() {
      return dataObjectBuilder != null;
    }

    /**
      * Clears the value of the 'dataObject' field.
      * @return This builder.
      */
    public Energistics.Protocol.Store.Object.Builder clearDataObject() {
      dataObject = null;
      dataObjectBuilder = null;
      fieldSetFlags()[0] = false;
      return this;
    }

    @Override
    public Object build() {
      try {
        Object record = new Object();
        if (dataObjectBuilder != null) {
          record.dataObject = this.dataObjectBuilder.build();
        } else {
          record.dataObject = fieldSetFlags()[0] ? this.dataObject : (Energistics.Datatypes.Object.DataObject) defaultValue(fields()[0]);
        }
        return record;
      } catch (Exception e) {
        throw new org.apache.avro.AvroRuntimeException(e);
      }
    }
  }

  private static final org.apache.avro.io.DatumWriter
    WRITER$ = new org.apache.avro.specific.SpecificDatumWriter(SCHEMA$);

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

  private static final org.apache.avro.io.DatumReader
    READER$ = new org.apache.avro.specific.SpecificDatumReader(SCHEMA$);

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

}