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