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 ProtobufQuaternion}
021 */
022@SuppressWarnings("hiding")
023public final class ProtobufQuaternion extends ProtoMessage<ProtobufQuaternion> implements Cloneable {
024  private static final long serialVersionUID = 0L;
025
026  /**
027   * <code>optional double w = 1;</code>
028   */
029  private double w;
030
031  /**
032   * <code>optional double x = 2;</code>
033   */
034  private double x;
035
036  /**
037   * <code>optional double y = 3;</code>
038   */
039  private double y;
040
041  /**
042   * <code>optional double z = 4;</code>
043   */
044  private double z;
045
046  private ProtobufQuaternion() {
047  }
048
049  /**
050   * @return a new empty instance of {@code ProtobufQuaternion}
051   */
052  public static ProtobufQuaternion newInstance() {
053    return new ProtobufQuaternion();
054  }
055
056  /**
057   * <code>optional double w = 1;</code>
058   * @return whether the w field is set
059   */
060  public boolean hasW() {
061    return (bitField0_ & 0x00000001) != 0;
062  }
063
064  /**
065   * <code>optional double w = 1;</code>
066   * @return this
067   */
068  public ProtobufQuaternion clearW() {
069    bitField0_ &= ~0x00000001;
070    w = 0D;
071    return this;
072  }
073
074  /**
075   * <code>optional double w = 1;</code>
076   * @return the w
077   */
078  public double getW() {
079    return w;
080  }
081
082  /**
083   * <code>optional double w = 1;</code>
084   * @param value the w to set
085   * @return this
086   */
087  public ProtobufQuaternion setW(final double value) {
088    bitField0_ |= 0x00000001;
089    w = value;
090    return this;
091  }
092
093  /**
094   * <code>optional double x = 2;</code>
095   * @return whether the x field is set
096   */
097  public boolean hasX() {
098    return (bitField0_ & 0x00000002) != 0;
099  }
100
101  /**
102   * <code>optional double x = 2;</code>
103   * @return this
104   */
105  public ProtobufQuaternion clearX() {
106    bitField0_ &= ~0x00000002;
107    x = 0D;
108    return this;
109  }
110
111  /**
112   * <code>optional double x = 2;</code>
113   * @return the x
114   */
115  public double getX() {
116    return x;
117  }
118
119  /**
120   * <code>optional double x = 2;</code>
121   * @param value the x to set
122   * @return this
123   */
124  public ProtobufQuaternion setX(final double value) {
125    bitField0_ |= 0x00000002;
126    x = value;
127    return this;
128  }
129
130  /**
131   * <code>optional double y = 3;</code>
132   * @return whether the y field is set
133   */
134  public boolean hasY() {
135    return (bitField0_ & 0x00000004) != 0;
136  }
137
138  /**
139   * <code>optional double y = 3;</code>
140   * @return this
141   */
142  public ProtobufQuaternion clearY() {
143    bitField0_ &= ~0x00000004;
144    y = 0D;
145    return this;
146  }
147
148  /**
149   * <code>optional double y = 3;</code>
150   * @return the y
151   */
152  public double getY() {
153    return y;
154  }
155
156  /**
157   * <code>optional double y = 3;</code>
158   * @param value the y to set
159   * @return this
160   */
161  public ProtobufQuaternion setY(final double value) {
162    bitField0_ |= 0x00000004;
163    y = value;
164    return this;
165  }
166
167  /**
168   * <code>optional double z = 4;</code>
169   * @return whether the z field is set
170   */
171  public boolean hasZ() {
172    return (bitField0_ & 0x00000008) != 0;
173  }
174
175  /**
176   * <code>optional double z = 4;</code>
177   * @return this
178   */
179  public ProtobufQuaternion clearZ() {
180    bitField0_ &= ~0x00000008;
181    z = 0D;
182    return this;
183  }
184
185  /**
186   * <code>optional double z = 4;</code>
187   * @return the z
188   */
189  public double getZ() {
190    return z;
191  }
192
193  /**
194   * <code>optional double z = 4;</code>
195   * @param value the z to set
196   * @return this
197   */
198  public ProtobufQuaternion setZ(final double value) {
199    bitField0_ |= 0x00000008;
200    z = value;
201    return this;
202  }
203
204  @Override
205  public ProtobufQuaternion copyFrom(final ProtobufQuaternion other) {
206    cachedSize = other.cachedSize;
207    if ((bitField0_ | other.bitField0_) != 0) {
208      bitField0_ = other.bitField0_;
209      w = other.w;
210      x = other.x;
211      y = other.y;
212      z = other.z;
213    }
214    return this;
215  }
216
217  @Override
218  public ProtobufQuaternion mergeFrom(final ProtobufQuaternion other) {
219    if (other.isEmpty()) {
220      return this;
221    }
222    cachedSize = -1;
223    if (other.hasW()) {
224      setW(other.w);
225    }
226    if (other.hasX()) {
227      setX(other.x);
228    }
229    if (other.hasY()) {
230      setY(other.y);
231    }
232    if (other.hasZ()) {
233      setZ(other.z);
234    }
235    return this;
236  }
237
238  @Override
239  public ProtobufQuaternion clear() {
240    if (isEmpty()) {
241      return this;
242    }
243    cachedSize = -1;
244    bitField0_ = 0;
245    w = 0D;
246    x = 0D;
247    y = 0D;
248    z = 0D;
249    return this;
250  }
251
252  @Override
253  public ProtobufQuaternion clearQuick() {
254    if (isEmpty()) {
255      return this;
256    }
257    cachedSize = -1;
258    bitField0_ = 0;
259    return this;
260  }
261
262  @Override
263  public boolean equals(Object o) {
264    if (o == this) {
265      return true;
266    }
267    if (!(o instanceof ProtobufQuaternion)) {
268      return false;
269    }
270    ProtobufQuaternion other = (ProtobufQuaternion) o;
271    return bitField0_ == other.bitField0_
272      && (!hasW() || ProtoUtil.isEqual(w, other.w))
273      && (!hasX() || ProtoUtil.isEqual(x, other.x))
274      && (!hasY() || ProtoUtil.isEqual(y, other.y))
275      && (!hasZ() || ProtoUtil.isEqual(z, other.z));
276  }
277
278  @Override
279  public void writeTo(final ProtoSink output) throws IOException {
280    if ((bitField0_ & 0x00000001) != 0) {
281      output.writeRawByte((byte) 9);
282      output.writeDoubleNoTag(w);
283    }
284    if ((bitField0_ & 0x00000002) != 0) {
285      output.writeRawByte((byte) 17);
286      output.writeDoubleNoTag(x);
287    }
288    if ((bitField0_ & 0x00000004) != 0) {
289      output.writeRawByte((byte) 25);
290      output.writeDoubleNoTag(y);
291    }
292    if ((bitField0_ & 0x00000008) != 0) {
293      output.writeRawByte((byte) 33);
294      output.writeDoubleNoTag(z);
295    }
296  }
297
298  @Override
299  protected int computeSerializedSize() {
300    int size = 0;
301    if ((bitField0_ & 0x00000001) != 0) {
302      size += 9;
303    }
304    if ((bitField0_ & 0x00000002) != 0) {
305      size += 9;
306    }
307    if ((bitField0_ & 0x00000004) != 0) {
308      size += 9;
309    }
310    if ((bitField0_ & 0x00000008) != 0) {
311      size += 9;
312    }
313    return size;
314  }
315
316  @Override
317  @SuppressWarnings("fallthrough")
318  public ProtobufQuaternion mergeFrom(final ProtoSource input) throws IOException {
319    // Enabled Fall-Through Optimization (QuickBuffers)
320    int tag = input.readTag();
321    while (true) {
322      switch (tag) {
323        case 9: {
324          // w
325          w = input.readDouble();
326          bitField0_ |= 0x00000001;
327          tag = input.readTag();
328          if (tag != 17) {
329            break;
330          }
331        }
332        case 17: {
333          // x
334          x = input.readDouble();
335          bitField0_ |= 0x00000002;
336          tag = input.readTag();
337          if (tag != 25) {
338            break;
339          }
340        }
341        case 25: {
342          // y
343          y = input.readDouble();
344          bitField0_ |= 0x00000004;
345          tag = input.readTag();
346          if (tag != 33) {
347            break;
348          }
349        }
350        case 33: {
351          // z
352          z = input.readDouble();
353          bitField0_ |= 0x00000008;
354          tag = input.readTag();
355          if (tag != 0) {
356            break;
357          }
358        }
359        case 0: {
360          return this;
361        }
362        default: {
363          if (!input.skipField(tag)) {
364            return this;
365          }
366          tag = input.readTag();
367          break;
368        }
369      }
370    }
371  }
372
373  @Override
374  public void writeTo(final JsonSink output) throws IOException {
375    output.beginObject();
376    if ((bitField0_ & 0x00000001) != 0) {
377      output.writeDouble(FieldNames.w, w);
378    }
379    if ((bitField0_ & 0x00000002) != 0) {
380      output.writeDouble(FieldNames.x, x);
381    }
382    if ((bitField0_ & 0x00000004) != 0) {
383      output.writeDouble(FieldNames.y, y);
384    }
385    if ((bitField0_ & 0x00000008) != 0) {
386      output.writeDouble(FieldNames.z, z);
387    }
388    output.endObject();
389  }
390
391  @Override
392  public ProtobufQuaternion mergeFrom(final JsonSource input) throws IOException {
393    if (!input.beginObject()) {
394      return this;
395    }
396    while (!input.isAtEnd()) {
397      switch (input.readFieldHash()) {
398        case 119: {
399          if (input.isAtField(FieldNames.w)) {
400            if (!input.trySkipNullValue()) {
401              w = input.readDouble();
402              bitField0_ |= 0x00000001;
403            }
404          } else {
405            input.skipUnknownField();
406          }
407          break;
408        }
409        case 120: {
410          if (input.isAtField(FieldNames.x)) {
411            if (!input.trySkipNullValue()) {
412              x = input.readDouble();
413              bitField0_ |= 0x00000002;
414            }
415          } else {
416            input.skipUnknownField();
417          }
418          break;
419        }
420        case 121: {
421          if (input.isAtField(FieldNames.y)) {
422            if (!input.trySkipNullValue()) {
423              y = input.readDouble();
424              bitField0_ |= 0x00000004;
425            }
426          } else {
427            input.skipUnknownField();
428          }
429          break;
430        }
431        case 122: {
432          if (input.isAtField(FieldNames.z)) {
433            if (!input.trySkipNullValue()) {
434              z = input.readDouble();
435              bitField0_ |= 0x00000008;
436            }
437          } else {
438            input.skipUnknownField();
439          }
440          break;
441        }
442        default: {
443          input.skipUnknownField();
444          break;
445        }
446      }
447    }
448    input.endObject();
449    return this;
450  }
451
452  @Override
453  public ProtobufQuaternion clone() {
454    return new ProtobufQuaternion().copyFrom(this);
455  }
456
457  @Override
458  public boolean isEmpty() {
459    return ((bitField0_) == 0);
460  }
461
462  public static ProtobufQuaternion parseFrom(final byte[] data) throws
463      InvalidProtocolBufferException {
464    return ProtoMessage.mergeFrom(new ProtobufQuaternion(), data).checkInitialized();
465  }
466
467  public static ProtobufQuaternion parseFrom(final ProtoSource input) throws IOException {
468    return ProtoMessage.mergeFrom(new ProtobufQuaternion(), input).checkInitialized();
469  }
470
471  public static ProtobufQuaternion parseFrom(final JsonSource input) throws IOException {
472    return ProtoMessage.mergeFrom(new ProtobufQuaternion(), input).checkInitialized();
473  }
474
475  /**
476   * @return factory for creating ProtobufQuaternion messages
477   */
478  public static MessageFactory<ProtobufQuaternion> getFactory() {
479    return ProtobufQuaternionFactory.INSTANCE;
480  }
481
482  /**
483   * @return this type's descriptor.
484   */
485  public static Descriptors.Descriptor getDescriptor() {
486    return ProtobufGeometry3dDescriptor.wpi_proto_ProtobufQuaternion_descriptor;
487  }
488
489  private enum ProtobufQuaternionFactory implements MessageFactory<ProtobufQuaternion> {
490    INSTANCE;
491
492    @Override
493    public ProtobufQuaternion create() {
494      return ProtobufQuaternion.newInstance();
495    }
496  }
497
498  /**
499   * Contains name constants used for serializing JSON
500   */
501  static class FieldNames {
502    static final FieldName w = FieldName.forField("w");
503
504    static final FieldName x = FieldName.forField("x");
505
506    static final FieldName y = FieldName.forField("y");
507
508    static final FieldName z = FieldName.forField("z");
509  }
510}