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