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