001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004// Code generated by protocol buffer compiler. Do not edit!
005package org.wpilib.math.proto;
006
007import java.io.IOException;
008import us.hebi.quickbuf.Descriptors;
009import us.hebi.quickbuf.FieldName;
010import us.hebi.quickbuf.InvalidProtocolBufferException;
011import us.hebi.quickbuf.JsonSink;
012import us.hebi.quickbuf.JsonSource;
013import us.hebi.quickbuf.MessageFactory;
014import us.hebi.quickbuf.ProtoMessage;
015import us.hebi.quickbuf.ProtoSink;
016import us.hebi.quickbuf.ProtoSource;
017import us.hebi.quickbuf.ProtoUtil;
018
019/**
020 * Protobuf type {@code ProtobufEllipse2d}
021 */
022@SuppressWarnings("hiding")
023public final class ProtobufEllipse2d extends ProtoMessage<ProtobufEllipse2d> implements Cloneable {
024  private static final long serialVersionUID = 0L;
025
026  /**
027   * <code>optional double xSemiAxis = 2;</code>
028   */
029  private double xSemiAxis;
030
031  /**
032   * <code>optional double ySemiAxis = 3;</code>
033   */
034  private double ySemiAxis;
035
036  /**
037   * <code>optional .wpi.proto.ProtobufPose2d center = 1;</code>
038   */
039  private final ProtobufPose2d center = ProtobufPose2d.newInstance();
040
041  private ProtobufEllipse2d() {
042  }
043
044  /**
045   * @return a new empty instance of {@code ProtobufEllipse2d}
046   */
047  public static ProtobufEllipse2d newInstance() {
048    return new ProtobufEllipse2d();
049  }
050
051  /**
052   * <code>optional double xSemiAxis = 2;</code>
053   * @return whether the xSemiAxis field is set
054   */
055  public boolean hasXSemiAxis() {
056    return (bitField0_ & 0x00000001) != 0;
057  }
058
059  /**
060   * <code>optional double xSemiAxis = 2;</code>
061   * @return this
062   */
063  public ProtobufEllipse2d clearXSemiAxis() {
064    bitField0_ &= ~0x00000001;
065    xSemiAxis = 0D;
066    return this;
067  }
068
069  /**
070   * <code>optional double xSemiAxis = 2;</code>
071   * @return the xSemiAxis
072   */
073  public double getXSemiAxis() {
074    return xSemiAxis;
075  }
076
077  /**
078   * <code>optional double xSemiAxis = 2;</code>
079   * @param value the xSemiAxis to set
080   * @return this
081   */
082  public ProtobufEllipse2d setXSemiAxis(final double value) {
083    bitField0_ |= 0x00000001;
084    xSemiAxis = value;
085    return this;
086  }
087
088  /**
089   * <code>optional double ySemiAxis = 3;</code>
090   * @return whether the ySemiAxis field is set
091   */
092  public boolean hasYSemiAxis() {
093    return (bitField0_ & 0x00000002) != 0;
094  }
095
096  /**
097   * <code>optional double ySemiAxis = 3;</code>
098   * @return this
099   */
100  public ProtobufEllipse2d clearYSemiAxis() {
101    bitField0_ &= ~0x00000002;
102    ySemiAxis = 0D;
103    return this;
104  }
105
106  /**
107   * <code>optional double ySemiAxis = 3;</code>
108   * @return the ySemiAxis
109   */
110  public double getYSemiAxis() {
111    return ySemiAxis;
112  }
113
114  /**
115   * <code>optional double ySemiAxis = 3;</code>
116   * @param value the ySemiAxis to set
117   * @return this
118   */
119  public ProtobufEllipse2d setYSemiAxis(final double value) {
120    bitField0_ |= 0x00000002;
121    ySemiAxis = value;
122    return this;
123  }
124
125  /**
126   * <code>optional .wpi.proto.ProtobufPose2d center = 1;</code>
127   * @return whether the center field is set
128   */
129  public boolean hasCenter() {
130    return (bitField0_ & 0x00000004) != 0;
131  }
132
133  /**
134   * <code>optional .wpi.proto.ProtobufPose2d center = 1;</code>
135   * @return this
136   */
137  public ProtobufEllipse2d clearCenter() {
138    bitField0_ &= ~0x00000004;
139    center.clear();
140    return this;
141  }
142
143  /**
144   * <code>optional .wpi.proto.ProtobufPose2d center = 1;</code>
145   *
146   * This method returns the internal storage object without modifying any has state.
147   * The returned object should not be modified and be treated as read-only.
148   *
149   * Use {@link #getMutableCenter()} if you want to modify it.
150   *
151   * @return internal storage object for reading
152   */
153  public ProtobufPose2d getCenter() {
154    return center;
155  }
156
157  /**
158   * <code>optional .wpi.proto.ProtobufPose2d center = 1;</code>
159   *
160   * This method returns the internal storage object and sets the corresponding
161   * has state. The returned object will become part of this message and its
162   * contents may be modified as long as the has state is not cleared.
163   *
164   * @return internal storage object for modifications
165   */
166  public ProtobufPose2d getMutableCenter() {
167    bitField0_ |= 0x00000004;
168    return center;
169  }
170
171  /**
172   * <code>optional .wpi.proto.ProtobufPose2d center = 1;</code>
173   * @param value the center to set
174   * @return this
175   */
176  public ProtobufEllipse2d setCenter(final ProtobufPose2d value) {
177    bitField0_ |= 0x00000004;
178    center.copyFrom(value);
179    return this;
180  }
181
182  @Override
183  public ProtobufEllipse2d copyFrom(final ProtobufEllipse2d other) {
184    cachedSize = other.cachedSize;
185    if ((bitField0_ | other.bitField0_) != 0) {
186      bitField0_ = other.bitField0_;
187      xSemiAxis = other.xSemiAxis;
188      ySemiAxis = other.ySemiAxis;
189      center.copyFrom(other.center);
190    }
191    return this;
192  }
193
194  @Override
195  public ProtobufEllipse2d mergeFrom(final ProtobufEllipse2d other) {
196    if (other.isEmpty()) {
197      return this;
198    }
199    cachedSize = -1;
200    if (other.hasXSemiAxis()) {
201      setXSemiAxis(other.xSemiAxis);
202    }
203    if (other.hasYSemiAxis()) {
204      setYSemiAxis(other.ySemiAxis);
205    }
206    if (other.hasCenter()) {
207      getMutableCenter().mergeFrom(other.center);
208    }
209    return this;
210  }
211
212  @Override
213  public ProtobufEllipse2d clear() {
214    if (isEmpty()) {
215      return this;
216    }
217    cachedSize = -1;
218    bitField0_ = 0;
219    xSemiAxis = 0D;
220    ySemiAxis = 0D;
221    center.clear();
222    return this;
223  }
224
225  @Override
226  public ProtobufEllipse2d clearQuick() {
227    if (isEmpty()) {
228      return this;
229    }
230    cachedSize = -1;
231    bitField0_ = 0;
232    center.clearQuick();
233    return this;
234  }
235
236  @Override
237  public boolean equals(Object o) {
238    if (o == this) {
239      return true;
240    }
241    if (!(o instanceof ProtobufEllipse2d)) {
242      return false;
243    }
244    ProtobufEllipse2d other = (ProtobufEllipse2d) o;
245    return bitField0_ == other.bitField0_
246      && (!hasXSemiAxis() || ProtoUtil.isEqual(xSemiAxis, other.xSemiAxis))
247      && (!hasYSemiAxis() || ProtoUtil.isEqual(ySemiAxis, other.ySemiAxis))
248      && (!hasCenter() || center.equals(other.center));
249  }
250
251  @Override
252  public void writeTo(final ProtoSink output) throws IOException {
253    if ((bitField0_ & 0x00000001) != 0) {
254      output.writeRawByte((byte) 17);
255      output.writeDoubleNoTag(xSemiAxis);
256    }
257    if ((bitField0_ & 0x00000002) != 0) {
258      output.writeRawByte((byte) 25);
259      output.writeDoubleNoTag(ySemiAxis);
260    }
261    if ((bitField0_ & 0x00000004) != 0) {
262      output.writeRawByte((byte) 10);
263      output.writeMessageNoTag(center);
264    }
265  }
266
267  @Override
268  protected int computeSerializedSize() {
269    int size = 0;
270    if ((bitField0_ & 0x00000001) != 0) {
271      size += 9;
272    }
273    if ((bitField0_ & 0x00000002) != 0) {
274      size += 9;
275    }
276    if ((bitField0_ & 0x00000004) != 0) {
277      size += 1 + ProtoSink.computeMessageSizeNoTag(center);
278    }
279    return size;
280  }
281
282  @Override
283  @SuppressWarnings("fallthrough")
284  public ProtobufEllipse2d mergeFrom(final ProtoSource input) throws IOException {
285    // Enabled Fall-Through Optimization (QuickBuffers)
286    int tag = input.readTag();
287    while (true) {
288      switch (tag) {
289        case 17: {
290          // xSemiAxis
291          xSemiAxis = input.readDouble();
292          bitField0_ |= 0x00000001;
293          tag = input.readTag();
294          if (tag != 25) {
295            break;
296          }
297        }
298        case 25: {
299          // ySemiAxis
300          ySemiAxis = input.readDouble();
301          bitField0_ |= 0x00000002;
302          tag = input.readTag();
303          if (tag != 10) {
304            break;
305          }
306        }
307        case 10: {
308          // center
309          input.readMessage(center);
310          bitField0_ |= 0x00000004;
311          tag = input.readTag();
312          if (tag != 0) {
313            break;
314          }
315        }
316        case 0: {
317          return this;
318        }
319        default: {
320          if (!input.skipField(tag)) {
321            return this;
322          }
323          tag = input.readTag();
324          break;
325        }
326      }
327    }
328  }
329
330  @Override
331  public void writeTo(final JsonSink output) throws IOException {
332    output.beginObject();
333    if ((bitField0_ & 0x00000001) != 0) {
334      output.writeDouble(FieldNames.xSemiAxis, xSemiAxis);
335    }
336    if ((bitField0_ & 0x00000002) != 0) {
337      output.writeDouble(FieldNames.ySemiAxis, ySemiAxis);
338    }
339    if ((bitField0_ & 0x00000004) != 0) {
340      output.writeMessage(FieldNames.center, center);
341    }
342    output.endObject();
343  }
344
345  @Override
346  public ProtobufEllipse2d mergeFrom(final JsonSource input) throws IOException {
347    if (!input.beginObject()) {
348      return this;
349    }
350    while (!input.isAtEnd()) {
351      switch (input.readFieldHash()) {
352        case -858640185: {
353          if (input.isAtField(FieldNames.xSemiAxis)) {
354            if (!input.trySkipNullValue()) {
355              xSemiAxis = input.readDouble();
356              bitField0_ |= 0x00000001;
357            }
358          } else {
359            input.skipUnknownField();
360          }
361          break;
362        }
363        case 1628872648: {
364          if (input.isAtField(FieldNames.ySemiAxis)) {
365            if (!input.trySkipNullValue()) {
366              ySemiAxis = input.readDouble();
367              bitField0_ |= 0x00000002;
368            }
369          } else {
370            input.skipUnknownField();
371          }
372          break;
373        }
374        case -1364013995: {
375          if (input.isAtField(FieldNames.center)) {
376            if (!input.trySkipNullValue()) {
377              input.readMessage(center);
378              bitField0_ |= 0x00000004;
379            }
380          } else {
381            input.skipUnknownField();
382          }
383          break;
384        }
385        default: {
386          input.skipUnknownField();
387          break;
388        }
389      }
390    }
391    input.endObject();
392    return this;
393  }
394
395  @Override
396  public ProtobufEllipse2d clone() {
397    return new ProtobufEllipse2d().copyFrom(this);
398  }
399
400  @Override
401  public boolean isEmpty() {
402    return ((bitField0_) == 0);
403  }
404
405  public static ProtobufEllipse2d parseFrom(final byte[] data) throws
406      InvalidProtocolBufferException {
407    return ProtoMessage.mergeFrom(new ProtobufEllipse2d(), data).checkInitialized();
408  }
409
410  public static ProtobufEllipse2d parseFrom(final ProtoSource input) throws IOException {
411    return ProtoMessage.mergeFrom(new ProtobufEllipse2d(), input).checkInitialized();
412  }
413
414  public static ProtobufEllipse2d parseFrom(final JsonSource input) throws IOException {
415    return ProtoMessage.mergeFrom(new ProtobufEllipse2d(), input).checkInitialized();
416  }
417
418  /**
419   * @return factory for creating ProtobufEllipse2d messages
420   */
421  public static MessageFactory<ProtobufEllipse2d> getFactory() {
422    return ProtobufEllipse2dFactory.INSTANCE;
423  }
424
425  /**
426   * @return this type's descriptor.
427   */
428  public static Descriptors.Descriptor getDescriptor() {
429    return ProtobufGeometry2dDescriptor.wpi_proto_ProtobufEllipse2d_descriptor;
430  }
431
432  private enum ProtobufEllipse2dFactory implements MessageFactory<ProtobufEllipse2d> {
433    INSTANCE;
434
435    @Override
436    public ProtobufEllipse2d create() {
437      return ProtobufEllipse2d.newInstance();
438    }
439  }
440
441  /**
442   * Contains name constants used for serializing JSON
443   */
444  static class FieldNames {
445    static final FieldName xSemiAxis = FieldName.forField("xSemiAxis");
446
447    static final FieldName ySemiAxis = FieldName.forField("ySemiAxis");
448
449    static final FieldName center = FieldName.forField("center");
450  }
451}