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