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