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