001/**
002 * Autogenerated by Avro
003 *
004 * DO NOT EDIT DIRECTLY
005 */
006package org.apache.reef.io.watcher.driver.context;
007
008import org.apache.avro.specific.SpecificData;
009
010@SuppressWarnings("all")
011@org.apache.avro.specific.AvroGenerated
012public class AvroActiveContext extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
013  private static final long serialVersionUID = 8797263879191499062L;
014  public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"AvroActiveContext\",\"namespace\":\"org.apache.reef.io.watcher.driver.context\",\"fields\":[{\"name\":\"base\",\"type\":{\"type\":\"record\",\"name\":\"AvroContextBase\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"evaluatorId\",\"type\":\"string\"},{\"name\":\"parentId\",\"type\":[\"string\",\"null\"]},{\"name\":\"evaluatorDescriptor\",\"type\":[{\"type\":\"record\",\"name\":\"AvroEvaluatorDescriptor\",\"namespace\":\"org.apache.reef.io.watcher.driver.evaluator\",\"fields\":[{\"name\":\"nodeDescriptor\",\"type\":{\"type\":\"record\",\"name\":\"AvroNodeDescriptor\",\"namespace\":\"org.apache.reef.io.watcher.driver.catalog\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"inetSocketAddress\",\"type\":\"string\"},{\"name\":\"rackDescriptor\",\"type\":{\"type\":\"record\",\"name\":\"AvroRackDescriptor\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"nodes\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"record\",\"name\":\"AvroNodeDescriptorInRackDescriptor\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"inetSocketAddress\",\"type\":\"string\"}]}}}]}}]}},{\"name\":\"process\",\"type\":{\"type\":\"record\",\"name\":\"AvroEvaluatorProcess\",\"fields\":[{\"name\":\"commandLines\",\"type\":{\"type\":\"array\",\"items\":[\"string\",\"null\"]}},{\"name\":\"evaluatorType\",\"type\":{\"type\":\"enum\",\"name\":\"AvroEvaluatorType\",\"symbols\":[\"JVM\",\"CLR\",\"UNDECIDED\"]}},{\"name\":\"isOptionSet\",\"type\":\"boolean\"}]}},{\"name\":\"memory\",\"type\":\"int\"},{\"name\":\"numberOfCores\",\"type\":\"int\"}]},\"null\"]}]}}]}");
015  public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
016  @Deprecated public org.apache.reef.io.watcher.driver.context.AvroContextBase base;
017
018  /**
019   * Default constructor.  Note that this does not initialize fields
020   * to their default values from the schema.  If that is desired then
021   * one should use <code>newBuilder()</code>.
022   */
023  public AvroActiveContext() {}
024
025  /**
026   * All-args constructor.
027   * @param base The new value for base
028   */
029  public AvroActiveContext(org.apache.reef.io.watcher.driver.context.AvroContextBase base) {
030    this.base = base;
031  }
032
033  public org.apache.avro.Schema getSchema() { return SCHEMA$; }
034  // Used by DatumWriter.  Applications should not call.
035  public java.lang.Object get(int field$) {
036    switch (field$) {
037    case 0: return base;
038    default: throw new org.apache.avro.AvroRuntimeException("Bad index");
039    }
040  }
041
042  // Used by DatumReader.  Applications should not call.
043  @SuppressWarnings(value="unchecked")
044  public void put(int field$, java.lang.Object value$) {
045    switch (field$) {
046    case 0: base = (org.apache.reef.io.watcher.driver.context.AvroContextBase)value$; break;
047    default: throw new org.apache.avro.AvroRuntimeException("Bad index");
048    }
049  }
050
051  /**
052   * Gets the value of the 'base' field.
053   * @return The value of the 'base' field.
054   */
055  public org.apache.reef.io.watcher.driver.context.AvroContextBase getBase() {
056    return base;
057  }
058
059  /**
060   * Sets the value of the 'base' field.
061   * @param value the value to set.
062   */
063  public void setBase(org.apache.reef.io.watcher.driver.context.AvroContextBase value) {
064    this.base = value;
065  }
066
067  /**
068   * Creates a new AvroActiveContext RecordBuilder.
069   * @return A new AvroActiveContext RecordBuilder
070   */
071  public static org.apache.reef.io.watcher.driver.context.AvroActiveContext.Builder newBuilder() {
072    return new org.apache.reef.io.watcher.driver.context.AvroActiveContext.Builder();
073  }
074
075  /**
076   * Creates a new AvroActiveContext RecordBuilder by copying an existing Builder.
077   * @param other The existing builder to copy.
078   * @return A new AvroActiveContext RecordBuilder
079   */
080  public static org.apache.reef.io.watcher.driver.context.AvroActiveContext.Builder newBuilder(org.apache.reef.io.watcher.driver.context.AvroActiveContext.Builder other) {
081    return new org.apache.reef.io.watcher.driver.context.AvroActiveContext.Builder(other);
082  }
083
084  /**
085   * Creates a new AvroActiveContext RecordBuilder by copying an existing AvroActiveContext instance.
086   * @param other The existing instance to copy.
087   * @return A new AvroActiveContext RecordBuilder
088   */
089  public static org.apache.reef.io.watcher.driver.context.AvroActiveContext.Builder newBuilder(org.apache.reef.io.watcher.driver.context.AvroActiveContext other) {
090    return new org.apache.reef.io.watcher.driver.context.AvroActiveContext.Builder(other);
091  }
092
093  /**
094   * RecordBuilder for AvroActiveContext instances.
095   */
096  public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<AvroActiveContext>
097    implements org.apache.avro.data.RecordBuilder<AvroActiveContext> {
098
099    private org.apache.reef.io.watcher.driver.context.AvroContextBase base;
100    private org.apache.reef.io.watcher.driver.context.AvroContextBase.Builder baseBuilder;
101
102    /** Creates a new Builder */
103    private Builder() {
104      super(SCHEMA$);
105    }
106
107    /**
108     * Creates a Builder by copying an existing Builder.
109     * @param other The existing Builder to copy.
110     */
111    private Builder(org.apache.reef.io.watcher.driver.context.AvroActiveContext.Builder other) {
112      super(other);
113      if (isValidValue(fields()[0], other.base)) {
114        this.base = data().deepCopy(fields()[0].schema(), other.base);
115        fieldSetFlags()[0] = true;
116      }
117      if (other.hasBaseBuilder()) {
118        this.baseBuilder = org.apache.reef.io.watcher.driver.context.AvroContextBase.newBuilder(other.getBaseBuilder());
119      }
120    }
121
122    /**
123     * Creates a Builder by copying an existing AvroActiveContext instance
124     * @param other The existing instance to copy.
125     */
126    private Builder(org.apache.reef.io.watcher.driver.context.AvroActiveContext other) {
127            super(SCHEMA$);
128      if (isValidValue(fields()[0], other.base)) {
129        this.base = data().deepCopy(fields()[0].schema(), other.base);
130        fieldSetFlags()[0] = true;
131      }
132      this.baseBuilder = null;
133    }
134
135    /**
136      * Gets the value of the 'base' field.
137      * @return The value.
138      */
139    public org.apache.reef.io.watcher.driver.context.AvroContextBase getBase() {
140      return base;
141    }
142
143    /**
144      * Sets the value of the 'base' field.
145      * @param value The value of 'base'.
146      * @return This builder.
147      */
148    public org.apache.reef.io.watcher.driver.context.AvroActiveContext.Builder setBase(org.apache.reef.io.watcher.driver.context.AvroContextBase value) {
149      validate(fields()[0], value);
150      this.baseBuilder = null;
151      this.base = value;
152      fieldSetFlags()[0] = true;
153      return this;
154    }
155
156    /**
157      * Checks whether the 'base' field has been set.
158      * @return True if the 'base' field has been set, false otherwise.
159      */
160    public boolean hasBase() {
161      return fieldSetFlags()[0];
162    }
163
164    /**
165     * Gets the Builder instance for the 'base' field and creates one if it doesn't exist yet.
166     * @return This builder.
167     */
168    public org.apache.reef.io.watcher.driver.context.AvroContextBase.Builder getBaseBuilder() {
169      if (baseBuilder == null) {
170        if (hasBase()) {
171          setBaseBuilder(org.apache.reef.io.watcher.driver.context.AvroContextBase.newBuilder(base));
172        } else {
173          setBaseBuilder(org.apache.reef.io.watcher.driver.context.AvroContextBase.newBuilder());
174        }
175      }
176      return baseBuilder;
177    }
178
179    /**
180     * Sets the Builder instance for the 'base' field
181     * @param value The builder instance that must be set.
182     * @return This builder.
183     */
184    public org.apache.reef.io.watcher.driver.context.AvroActiveContext.Builder setBaseBuilder(org.apache.reef.io.watcher.driver.context.AvroContextBase.Builder value) {
185      clearBase();
186      baseBuilder = value;
187      return this;
188    }
189
190    /**
191     * Checks whether the 'base' field has an active Builder instance
192     * @return True if the 'base' field has an active Builder instance
193     */
194    public boolean hasBaseBuilder() {
195      return baseBuilder != null;
196    }
197
198    /**
199      * Clears the value of the 'base' field.
200      * @return This builder.
201      */
202    public org.apache.reef.io.watcher.driver.context.AvroActiveContext.Builder clearBase() {
203      base = null;
204      baseBuilder = null;
205      fieldSetFlags()[0] = false;
206      return this;
207    }
208
209    @Override
210    public AvroActiveContext build() {
211      try {
212        AvroActiveContext record = new AvroActiveContext();
213        if (baseBuilder != null) {
214          record.base = this.baseBuilder.build();
215        } else {
216          record.base = fieldSetFlags()[0] ? this.base : (org.apache.reef.io.watcher.driver.context.AvroContextBase) defaultValue(fields()[0]);
217        }
218        return record;
219      } catch (Exception e) {
220        throw new org.apache.avro.AvroRuntimeException(e);
221      }
222    }
223  }
224
225  private static final org.apache.avro.io.DatumWriter
226    WRITER$ = new org.apache.avro.specific.SpecificDatumWriter(SCHEMA$);
227
228  @Override public void writeExternal(java.io.ObjectOutput out)
229    throws java.io.IOException {
230    WRITER$.write(this, SpecificData.getEncoder(out));
231  }
232
233  private static final org.apache.avro.io.DatumReader
234    READER$ = new org.apache.avro.specific.SpecificDatumReader(SCHEMA$);
235
236  @Override public void readExternal(java.io.ObjectInput in)
237    throws java.io.IOException {
238    READER$.read(this, SpecificData.getDecoder(in));
239  }
240
241}