RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
ProtobufTranslation2d.java
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4// Code generated by protocol buffer compiler. Do not edit!
5package org.wpilib.math.geometry.proto.detail;
6
7import java.io.IOException;
8import us.hebi.quickbuf.Descriptors;
9import us.hebi.quickbuf.FieldName;
10import us.hebi.quickbuf.InvalidProtocolBufferException;
11import us.hebi.quickbuf.JsonSink;
12import us.hebi.quickbuf.JsonSource;
13import us.hebi.quickbuf.MessageFactory;
14import us.hebi.quickbuf.ProtoMessage;
15import us.hebi.quickbuf.ProtoSink;
16import us.hebi.quickbuf.ProtoSource;
17import us.hebi.quickbuf.ProtoUtil;
18
22@SuppressWarnings("hiding")
23public final class ProtobufTranslation2d extends ProtoMessage<ProtobufTranslation2d> implements Cloneable {
24 private static final long serialVersionUID = 0L;
25
29 private double x;
30
34 private double y;
35
36 private ProtobufTranslation2d() {
37 }
38
42 public static ProtobufTranslation2d newInstance() {
43 return new ProtobufTranslation2d();
44 }
45
50 public boolean hasX() {
51 return (bitField0_ & 0x00000001) != 0;
52 }
53
58 public ProtobufTranslation2d clearX() {
59 bitField0_ &= ~0x00000001;
60 x = 0D;
61 return this;
62 }
63
68 public double getX() {
69 return x;
70 }
71
77 public ProtobufTranslation2d setX(final double value) {
78 bitField0_ |= 0x00000001;
79 x = value;
80 return this;
81 }
82
87 public boolean hasY() {
88 return (bitField0_ & 0x00000002) != 0;
89 }
90
95 public ProtobufTranslation2d clearY() {
96 bitField0_ &= ~0x00000002;
97 y = 0D;
98 return this;
99 }
100
105 public double getY() {
106 return y;
107 }
108
114 public ProtobufTranslation2d setY(final double value) {
115 bitField0_ |= 0x00000002;
116 y = value;
117 return this;
118 }
119
120 @Override
121 public ProtobufTranslation2d copyFrom(final ProtobufTranslation2d other) {
122 cachedSize = other.cachedSize;
123 if ((bitField0_ | other.bitField0_) != 0) {
124 bitField0_ = other.bitField0_;
125 x = other.x;
126 y = other.y;
127 }
128 return this;
129 }
130
131 @Override
132 public ProtobufTranslation2d mergeFrom(final ProtobufTranslation2d other) {
133 if (other.isEmpty()) {
134 return this;
135 }
136 cachedSize = -1;
137 if (other.hasX()) {
138 setX(other.x);
139 }
140 if (other.hasY()) {
141 setY(other.y);
142 }
143 return this;
144 }
145
146 @Override
147 public ProtobufTranslation2d clear() {
148 if (isEmpty()) {
149 return this;
150 }
151 cachedSize = -1;
152 bitField0_ = 0;
153 x = 0D;
154 y = 0D;
155 return this;
156 }
157
158 @Override
159 public ProtobufTranslation2d clearQuick() {
160 if (isEmpty()) {
161 return this;
162 }
163 cachedSize = -1;
164 bitField0_ = 0;
165 return this;
166 }
167
168 @Override
169 public boolean equals(Object o) {
170 if (o == this) {
171 return true;
172 }
173 if (!(o instanceof ProtobufTranslation2d)) {
174 return false;
175 }
177 return bitField0_ == other.bitField0_
178 && (!hasX() || ProtoUtil.isEqual(x, other.x))
179 && (!hasY() || ProtoUtil.isEqual(y, other.y));
180 }
181
182 @Override
183 public void writeTo(final ProtoSink output) throws IOException {
184 if ((bitField0_ & 0x00000001) != 0) {
185 output.writeRawByte((byte) 9);
186 output.writeDoubleNoTag(x);
187 }
188 if ((bitField0_ & 0x00000002) != 0) {
189 output.writeRawByte((byte) 17);
190 output.writeDoubleNoTag(y);
191 }
192 }
193
194 @Override
195 protected int computeSerializedSize() {
196 int size = 0;
197 if ((bitField0_ & 0x00000001) != 0) {
198 size += 9;
199 }
200 if ((bitField0_ & 0x00000002) != 0) {
201 size += 9;
202 }
203 return size;
204 }
205
206 @Override
207 @SuppressWarnings("fallthrough")
208 public ProtobufTranslation2d mergeFrom(final ProtoSource input) throws IOException {
209 // Enabled Fall-Through Optimization (QuickBuffers)
210 int tag = input.readTag();
211 while (true) {
212 switch (tag) {
213 case 9: {
214 // x
215 x = input.readDouble();
216 bitField0_ |= 0x00000001;
217 tag = input.readTag();
218 if (tag != 17) {
219 break;
220 }
221 }
222 case 17: {
223 // y
224 y = input.readDouble();
225 bitField0_ |= 0x00000002;
226 tag = input.readTag();
227 if (tag != 0) {
228 break;
229 }
230 }
231 case 0: {
232 return this;
233 }
234 default: {
235 if (!input.skipField(tag)) {
236 return this;
237 }
238 tag = input.readTag();
239 break;
240 }
241 }
242 }
243 }
244
245 @Override
246 public void writeTo(final JsonSink output) throws IOException {
247 output.beginObject();
248 if ((bitField0_ & 0x00000001) != 0) {
249 output.writeDouble(FieldNames.x, x);
250 }
251 if ((bitField0_ & 0x00000002) != 0) {
252 output.writeDouble(FieldNames.y, y);
253 }
254 output.endObject();
255 }
256
257 @Override
258 public ProtobufTranslation2d mergeFrom(final JsonSource input) throws IOException {
259 if (!input.beginObject()) {
260 return this;
261 }
262 while (!input.isAtEnd()) {
263 switch (input.readFieldHash()) {
264 case 120: {
265 if (input.isAtField(FieldNames.x)) {
266 if (!input.trySkipNullValue()) {
267 x = input.readDouble();
268 bitField0_ |= 0x00000001;
269 }
270 } else {
271 input.skipUnknownField();
272 }
273 break;
274 }
275 case 121: {
276 if (input.isAtField(FieldNames.y)) {
277 if (!input.trySkipNullValue()) {
278 y = input.readDouble();
279 bitField0_ |= 0x00000002;
280 }
281 } else {
282 input.skipUnknownField();
283 }
284 break;
285 }
286 default: {
287 input.skipUnknownField();
288 break;
289 }
290 }
291 }
292 input.endObject();
293 return this;
294 }
295
296 @Override
297 public ProtobufTranslation2d clone() {
298 return new ProtobufTranslation2d().copyFrom(this);
299 }
300
301 @Override
302 public boolean isEmpty() {
303 return ((bitField0_) == 0);
304 }
305
306 public static ProtobufTranslation2d parseFrom(final byte[] data) throws
307 InvalidProtocolBufferException {
308 return ProtoMessage.mergeFrom(new ProtobufTranslation2d(), data).checkInitialized();
309 }
310
311 public static ProtobufTranslation2d parseFrom(final ProtoSource input) throws IOException {
312 return ProtoMessage.mergeFrom(new ProtobufTranslation2d(), input).checkInitialized();
313 }
314
315 public static ProtobufTranslation2d parseFrom(final JsonSource input) throws IOException {
316 return ProtoMessage.mergeFrom(new ProtobufTranslation2d(), input).checkInitialized();
317 }
318
322 public static MessageFactory<ProtobufTranslation2d> getFactory() {
323 return ProtobufTranslation2dFactory.INSTANCE;
324 }
325
329 public static Descriptors.Descriptor getDescriptor() {
330 return ProtobufGeometry2dDescriptor.wpi_proto_ProtobufTranslation2d_descriptor;
331 }
332
333 private enum ProtobufTranslation2dFactory implements MessageFactory<ProtobufTranslation2d> {
334 INSTANCE;
335
336 @Override
337 public ProtobufTranslation2d create() {
338 return ProtobufTranslation2d.newInstance();
339 }
340 }
341
345 static class FieldNames {
346 static final FieldName x = FieldName.forField("x");
347
348 static final FieldName y = FieldName.forField("y");
349 }
350}
static MessageFactory< ProtobufTranslation2d > getFactory()