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