RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
ProtobufMatrix.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.linalg.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.RepeatedDouble;
18
22@SuppressWarnings("hiding")
23public final class ProtobufMatrix extends ProtoMessage<ProtobufMatrix> implements Cloneable {
24 private static final long serialVersionUID = 0L;
25
29 private int numRows;
30
34 private int numCols;
35
39 private final RepeatedDouble data = RepeatedDouble.newEmptyInstance();
40
41 private ProtobufMatrix() {
42 }
43
47 public static ProtobufMatrix newInstance() {
48 return new ProtobufMatrix();
49 }
50
55 public boolean hasNumRows() {
56 return (bitField0_ & 0x00000001) != 0;
57 }
58
63 public ProtobufMatrix clearNumRows() {
64 bitField0_ &= ~0x00000001;
65 numRows = 0;
66 return this;
67 }
68
73 public int getNumRows() {
74 return numRows;
75 }
76
82 public ProtobufMatrix setNumRows(final int value) {
83 bitField0_ |= 0x00000001;
84 numRows = value;
85 return this;
86 }
87
92 public boolean hasNumCols() {
93 return (bitField0_ & 0x00000002) != 0;
94 }
95
100 public ProtobufMatrix clearNumCols() {
101 bitField0_ &= ~0x00000002;
102 numCols = 0;
103 return this;
104 }
105
110 public int getNumCols() {
111 return numCols;
112 }
113
119 public ProtobufMatrix setNumCols(final int value) {
120 bitField0_ |= 0x00000002;
121 numCols = value;
122 return this;
123 }
124
129 public boolean hasData() {
130 return (bitField0_ & 0x00000004) != 0;
131 }
132
137 public ProtobufMatrix clearData() {
138 bitField0_ &= ~0x00000004;
139 data.clear();
140 return this;
141 }
142
153 public RepeatedDouble getData() {
154 return data;
155 }
156
166 public RepeatedDouble getMutableData() {
167 bitField0_ |= 0x00000004;
168 return data;
169 }
170
176 public ProtobufMatrix addData(final double value) {
177 bitField0_ |= 0x00000004;
178 data.add(value);
179 return this;
180 }
181
187 public ProtobufMatrix addAllData(final double... values) {
188 bitField0_ |= 0x00000004;
189 data.addAll(values);
190 return this;
191 }
192
193 @Override
194 public ProtobufMatrix copyFrom(final ProtobufMatrix other) {
195 cachedSize = other.cachedSize;
196 if ((bitField0_ | other.bitField0_) != 0) {
197 bitField0_ = other.bitField0_;
198 numRows = other.numRows;
199 numCols = other.numCols;
200 data.copyFrom(other.data);
201 }
202 return this;
203 }
204
205 @Override
206 public ProtobufMatrix mergeFrom(final ProtobufMatrix other) {
207 if (other.isEmpty()) {
208 return this;
209 }
210 cachedSize = -1;
211 if (other.hasNumRows()) {
212 setNumRows(other.numRows);
213 }
214 if (other.hasNumCols()) {
215 setNumCols(other.numCols);
216 }
217 if (other.hasData()) {
218 getMutableData().addAll(other.data);
219 }
220 return this;
221 }
222
223 @Override
224 public ProtobufMatrix clear() {
225 if (isEmpty()) {
226 return this;
227 }
228 cachedSize = -1;
229 bitField0_ = 0;
230 numRows = 0;
231 numCols = 0;
232 data.clear();
233 return this;
234 }
235
236 @Override
237 public ProtobufMatrix clearQuick() {
238 if (isEmpty()) {
239 return this;
240 }
241 cachedSize = -1;
242 bitField0_ = 0;
243 data.clear();
244 return this;
245 }
246
247 @Override
248 public boolean equals(Object o) {
249 if (o == this) {
250 return true;
251 }
252 if (!(o instanceof ProtobufMatrix)) {
253 return false;
254 }
255 ProtobufMatrix other = (ProtobufMatrix) o;
256 return bitField0_ == other.bitField0_
257 && (!hasNumRows() || numRows == other.numRows)
258 && (!hasNumCols() || numCols == other.numCols)
259 && (!hasData() || data.equals(other.data));
260 }
261
262 @Override
263 public void writeTo(final ProtoSink output) throws IOException {
264 if ((bitField0_ & 0x00000001) != 0) {
265 output.writeRawByte((byte) 8);
266 output.writeUInt32NoTag(numRows);
267 }
268 if ((bitField0_ & 0x00000002) != 0) {
269 output.writeRawByte((byte) 16);
270 output.writeUInt32NoTag(numCols);
271 }
272 if ((bitField0_ & 0x00000004) != 0) {
273 for (int i = 0; i < data.length(); i++) {
274 output.writeRawByte((byte) 25);
275 output.writeDoubleNoTag(data.array()[i]);
276 }
277 }
278 }
279
280 @Override
281 protected int computeSerializedSize() {
282 int size = 0;
283 if ((bitField0_ & 0x00000001) != 0) {
284 size += 1 + ProtoSink.computeUInt32SizeNoTag(numRows);
285 }
286 if ((bitField0_ & 0x00000002) != 0) {
287 size += 1 + ProtoSink.computeUInt32SizeNoTag(numCols);
288 }
289 if ((bitField0_ & 0x00000004) != 0) {
290 size += (1 + 8) * data.length();
291 }
292 return size;
293 }
294
295 @Override
296 @SuppressWarnings("fallthrough")
297 public ProtobufMatrix mergeFrom(final ProtoSource input) throws IOException {
298 // Enabled Fall-Through Optimization (QuickBuffers)
299 int tag = input.readTag();
300 while (true) {
301 switch (tag) {
302 case 8: {
303 // numRows
304 numRows = input.readUInt32();
305 bitField0_ |= 0x00000001;
306 tag = input.readTag();
307 if (tag != 16) {
308 break;
309 }
310 }
311 case 16: {
312 // numCols
313 numCols = input.readUInt32();
314 bitField0_ |= 0x00000002;
315 tag = input.readTag();
316 if (tag != 26) {
317 break;
318 }
319 }
320 case 26: {
321 // data [packed=true]
322 input.readPackedDouble(data);
323 bitField0_ |= 0x00000004;
324 tag = input.readTag();
325 if (tag != 0) {
326 break;
327 }
328 }
329 case 0: {
330 return this;
331 }
332 default: {
333 if (!input.skipField(tag)) {
334 return this;
335 }
336 tag = input.readTag();
337 break;
338 }
339 case 25: {
340 // data [packed=false]
341 tag = input.readRepeatedDouble(data, tag);
342 bitField0_ |= 0x00000004;
343 break;
344 }
345 }
346 }
347 }
348
349 @Override
350 public void writeTo(final JsonSink output) throws IOException {
351 output.beginObject();
352 if ((bitField0_ & 0x00000001) != 0) {
353 output.writeUInt32(FieldNames.numRows, numRows);
354 }
355 if ((bitField0_ & 0x00000002) != 0) {
356 output.writeUInt32(FieldNames.numCols, numCols);
357 }
358 if ((bitField0_ & 0x00000004) != 0) {
359 output.writeRepeatedDouble(FieldNames.data, data);
360 }
361 output.endObject();
362 }
363
364 @Override
365 public ProtobufMatrix mergeFrom(final JsonSource input) throws IOException {
366 if (!input.beginObject()) {
367 return this;
368 }
369 while (!input.isAtEnd()) {
370 switch (input.readFieldHash()) {
371 case -2000982401:
372 case -1888824590: {
373 if (input.isAtField(FieldNames.numRows)) {
374 if (!input.trySkipNullValue()) {
375 numRows = input.readUInt32();
376 bitField0_ |= 0x00000001;
377 }
378 } else {
379 input.skipUnknownField();
380 }
381 break;
382 }
383 case -2001429607:
384 case -1889271796: {
385 if (input.isAtField(FieldNames.numCols)) {
386 if (!input.trySkipNullValue()) {
387 numCols = input.readUInt32();
388 bitField0_ |= 0x00000002;
389 }
390 } else {
391 input.skipUnknownField();
392 }
393 break;
394 }
395 case 3076010: {
396 if (input.isAtField(FieldNames.data)) {
397 if (!input.trySkipNullValue()) {
398 input.readRepeatedDouble(data);
399 bitField0_ |= 0x00000004;
400 }
401 } else {
402 input.skipUnknownField();
403 }
404 break;
405 }
406 default: {
407 input.skipUnknownField();
408 break;
409 }
410 }
411 }
412 input.endObject();
413 return this;
414 }
415
416 @Override
417 public ProtobufMatrix clone() {
418 return new ProtobufMatrix().copyFrom(this);
419 }
420
421 @Override
422 public boolean isEmpty() {
423 return ((bitField0_) == 0);
424 }
425
426 public static ProtobufMatrix parseFrom(final byte[] data) throws InvalidProtocolBufferException {
427 return ProtoMessage.mergeFrom(new ProtobufMatrix(), data).checkInitialized();
428 }
429
430 public static ProtobufMatrix parseFrom(final ProtoSource input) throws IOException {
431 return ProtoMessage.mergeFrom(new ProtobufMatrix(), input).checkInitialized();
432 }
433
434 public static ProtobufMatrix parseFrom(final JsonSource input) throws IOException {
435 return ProtoMessage.mergeFrom(new ProtobufMatrix(), input).checkInitialized();
436 }
437
441 public static MessageFactory<ProtobufMatrix> getFactory() {
442 return ProtobufMatrixFactory.INSTANCE;
443 }
444
448 public static Descriptors.Descriptor getDescriptor() {
449 return ProtobufWPIMathDescriptor.wpi_proto_ProtobufMatrix_descriptor;
450 }
451
452 private enum ProtobufMatrixFactory implements MessageFactory<ProtobufMatrix> {
453 INSTANCE;
454
455 @Override
456 public ProtobufMatrix create() {
457 return ProtobufMatrix.newInstance();
458 }
459 }
460
464 static class FieldNames {
465 static final FieldName numRows = FieldName.forField("numRows", "num_rows");
466
467 static final FieldName numCols = FieldName.forField("numCols", "num_cols");
468
469 static final FieldName data = FieldName.forField("data");
470 }
471}
static MessageFactory< ProtobufMatrix > getFactory()
ProtobufMatrix addAllData(final double... values)