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.RepeatedMessage;
018
019/**
020 * Protobuf type {@code ProtobufSwerveDriveKinematics}
021 */
022@SuppressWarnings("hiding")
023public final class ProtobufSwerveDriveKinematics extends ProtoMessage<ProtobufSwerveDriveKinematics> implements Cloneable {
024  private static final long serialVersionUID = 0L;
025
026  /**
027   * <code>repeated .wpi.proto.ProtobufTranslation2d modules = 1;</code>
028   */
029  private final RepeatedMessage<ProtobufTranslation2d> modules = RepeatedMessage.newEmptyInstance(ProtobufTranslation2d.getFactory());
030
031  private ProtobufSwerveDriveKinematics() {
032  }
033
034  /**
035   * @return a new empty instance of {@code ProtobufSwerveDriveKinematics}
036   */
037  public static ProtobufSwerveDriveKinematics newInstance() {
038    return new ProtobufSwerveDriveKinematics();
039  }
040
041  /**
042   * <code>repeated .wpi.proto.ProtobufTranslation2d modules = 1;</code>
043   * @return whether the modules field is set
044   */
045  public boolean hasModules() {
046    return (bitField0_ & 0x00000001) != 0;
047  }
048
049  /**
050   * <code>repeated .wpi.proto.ProtobufTranslation2d modules = 1;</code>
051   * @return this
052   */
053  public ProtobufSwerveDriveKinematics clearModules() {
054    bitField0_ &= ~0x00000001;
055    modules.clear();
056    return this;
057  }
058
059  /**
060   * <code>repeated .wpi.proto.ProtobufTranslation2d modules = 1;</code>
061   *
062   * This method returns the internal storage object without modifying any has state.
063   * The returned object should not be modified and be treated as read-only.
064   *
065   * Use {@link #getMutableModules()} if you want to modify it.
066   *
067   * @return internal storage object for reading
068   */
069  public RepeatedMessage<ProtobufTranslation2d> getModules() {
070    return modules;
071  }
072
073  /**
074   * <code>repeated .wpi.proto.ProtobufTranslation2d modules = 1;</code>
075   *
076   * This method returns the internal storage object and sets the corresponding
077   * has state. The returned object will become part of this message and its
078   * contents may be modified as long as the has state is not cleared.
079   *
080   * @return internal storage object for modifications
081   */
082  public RepeatedMessage<ProtobufTranslation2d> getMutableModules() {
083    bitField0_ |= 0x00000001;
084    return modules;
085  }
086
087  /**
088   * <code>repeated .wpi.proto.ProtobufTranslation2d modules = 1;</code>
089   * @param value the modules to add
090   * @return this
091   */
092  public ProtobufSwerveDriveKinematics addModules(final ProtobufTranslation2d value) {
093    bitField0_ |= 0x00000001;
094    modules.add(value);
095    return this;
096  }
097
098  /**
099   * <code>repeated .wpi.proto.ProtobufTranslation2d modules = 1;</code>
100   * @param values the modules to add
101   * @return this
102   */
103  public ProtobufSwerveDriveKinematics addAllModules(final ProtobufTranslation2d... values) {
104    bitField0_ |= 0x00000001;
105    modules.addAll(values);
106    return this;
107  }
108
109  @Override
110  public ProtobufSwerveDriveKinematics copyFrom(final ProtobufSwerveDriveKinematics other) {
111    cachedSize = other.cachedSize;
112    if ((bitField0_ | other.bitField0_) != 0) {
113      bitField0_ = other.bitField0_;
114      modules.copyFrom(other.modules);
115    }
116    return this;
117  }
118
119  @Override
120  public ProtobufSwerveDriveKinematics mergeFrom(final ProtobufSwerveDriveKinematics other) {
121    if (other.isEmpty()) {
122      return this;
123    }
124    cachedSize = -1;
125    if (other.hasModules()) {
126      getMutableModules().addAll(other.modules);
127    }
128    return this;
129  }
130
131  @Override
132  public ProtobufSwerveDriveKinematics clear() {
133    if (isEmpty()) {
134      return this;
135    }
136    cachedSize = -1;
137    bitField0_ = 0;
138    modules.clear();
139    return this;
140  }
141
142  @Override
143  public ProtobufSwerveDriveKinematics clearQuick() {
144    if (isEmpty()) {
145      return this;
146    }
147    cachedSize = -1;
148    bitField0_ = 0;
149    modules.clearQuick();
150    return this;
151  }
152
153  @Override
154  public boolean equals(Object o) {
155    if (o == this) {
156      return true;
157    }
158    if (!(o instanceof ProtobufSwerveDriveKinematics)) {
159      return false;
160    }
161    ProtobufSwerveDriveKinematics other = (ProtobufSwerveDriveKinematics) o;
162    return bitField0_ == other.bitField0_
163      && (!hasModules() || modules.equals(other.modules));
164  }
165
166  @Override
167  public void writeTo(final ProtoSink output) throws IOException {
168    if ((bitField0_ & 0x00000001) != 0) {
169      for (int i = 0; i < modules.length(); i++) {
170        output.writeRawByte((byte) 10);
171        output.writeMessageNoTag(modules.get(i));
172      }
173    }
174  }
175
176  @Override
177  protected int computeSerializedSize() {
178    int size = 0;
179    if ((bitField0_ & 0x00000001) != 0) {
180      size += (1 * modules.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(modules);
181    }
182    return size;
183  }
184
185  @Override
186  @SuppressWarnings("fallthrough")
187  public ProtobufSwerveDriveKinematics mergeFrom(final ProtoSource input) throws IOException {
188    // Enabled Fall-Through Optimization (QuickBuffers)
189    int tag = input.readTag();
190    while (true) {
191      switch (tag) {
192        case 10: {
193          // modules
194          tag = input.readRepeatedMessage(modules, tag);
195          bitField0_ |= 0x00000001;
196          if (tag != 0) {
197            break;
198          }
199        }
200        case 0: {
201          return this;
202        }
203        default: {
204          if (!input.skipField(tag)) {
205            return this;
206          }
207          tag = input.readTag();
208          break;
209        }
210      }
211    }
212  }
213
214  @Override
215  public void writeTo(final JsonSink output) throws IOException {
216    output.beginObject();
217    if ((bitField0_ & 0x00000001) != 0) {
218      output.writeRepeatedMessage(FieldNames.modules, modules);
219    }
220    output.endObject();
221  }
222
223  @Override
224  public ProtobufSwerveDriveKinematics mergeFrom(final JsonSource input) throws IOException {
225    if (!input.beginObject()) {
226      return this;
227    }
228    while (!input.isAtEnd()) {
229      switch (input.readFieldHash()) {
230        case 1227433863: {
231          if (input.isAtField(FieldNames.modules)) {
232            if (!input.trySkipNullValue()) {
233              input.readRepeatedMessage(modules);
234              bitField0_ |= 0x00000001;
235            }
236          } else {
237            input.skipUnknownField();
238          }
239          break;
240        }
241        default: {
242          input.skipUnknownField();
243          break;
244        }
245      }
246    }
247    input.endObject();
248    return this;
249  }
250
251  @Override
252  public ProtobufSwerveDriveKinematics clone() {
253    return new ProtobufSwerveDriveKinematics().copyFrom(this);
254  }
255
256  @Override
257  public boolean isEmpty() {
258    return ((bitField0_) == 0);
259  }
260
261  public static ProtobufSwerveDriveKinematics parseFrom(final byte[] data) throws
262      InvalidProtocolBufferException {
263    return ProtoMessage.mergeFrom(new ProtobufSwerveDriveKinematics(), data).checkInitialized();
264  }
265
266  public static ProtobufSwerveDriveKinematics parseFrom(final ProtoSource input) throws
267      IOException {
268    return ProtoMessage.mergeFrom(new ProtobufSwerveDriveKinematics(), input).checkInitialized();
269  }
270
271  public static ProtobufSwerveDriveKinematics parseFrom(final JsonSource input) throws IOException {
272    return ProtoMessage.mergeFrom(new ProtobufSwerveDriveKinematics(), input).checkInitialized();
273  }
274
275  /**
276   * @return factory for creating ProtobufSwerveDriveKinematics messages
277   */
278  public static MessageFactory<ProtobufSwerveDriveKinematics> getFactory() {
279    return ProtobufSwerveDriveKinematicsFactory.INSTANCE;
280  }
281
282  /**
283   * @return this type's descriptor.
284   */
285  public static Descriptors.Descriptor getDescriptor() {
286    return ProtobufKinematicsDescriptor.wpi_proto_ProtobufSwerveDriveKinematics_descriptor;
287  }
288
289  private enum ProtobufSwerveDriveKinematicsFactory implements MessageFactory<ProtobufSwerveDriveKinematics> {
290    INSTANCE;
291
292    @Override
293    public ProtobufSwerveDriveKinematics create() {
294      return ProtobufSwerveDriveKinematics.newInstance();
295    }
296  }
297
298  /**
299   * Contains name constants used for serializing JSON
300   */
301  static class FieldNames {
302    static final FieldName modules = FieldName.forField("modules");
303  }
304}