RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
ProtobufVector.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 ProtobufVector extends ProtoMessage<ProtobufVector> implements Cloneable {
24 private static final long serialVersionUID = 0L;
25
29 private final RepeatedDouble rows = RepeatedDouble.newEmptyInstance();
30
31 private ProtobufVector() {
32 }
33
37 public static ProtobufVector newInstance() {
38 return new ProtobufVector();
39 }
40
45 public boolean hasRows() {
46 return (bitField0_ & 0x00000001) != 0;
47 }
48
53 public ProtobufVector clearRows() {
54 bitField0_ &= ~0x00000001;
55 rows.clear();
56 return this;
57 }
58
69 public RepeatedDouble getRows() {
70 return rows;
71 }
72
82 public RepeatedDouble getMutableRows() {
83 bitField0_ |= 0x00000001;
84 return rows;
85 }
86
92 public ProtobufVector addRows(final double value) {
93 bitField0_ |= 0x00000001;
94 rows.add(value);
95 return this;
96 }
97
103 public ProtobufVector addAllRows(final double... values) {
104 bitField0_ |= 0x00000001;
105 rows.addAll(values);
106 return this;
107 }
108
109 @Override
110 public ProtobufVector copyFrom(final ProtobufVector other) {
111 cachedSize = other.cachedSize;
112 if ((bitField0_ | other.bitField0_) != 0) {
113 bitField0_ = other.bitField0_;
114 rows.copyFrom(other.rows);
115 }
116 return this;
117 }
118
119 @Override
120 public ProtobufVector mergeFrom(final ProtobufVector other) {
121 if (other.isEmpty()) {
122 return this;
123 }
124 cachedSize = -1;
125 if (other.hasRows()) {
126 getMutableRows().addAll(other.rows);
127 }
128 return this;
129 }
130
131 @Override
132 public ProtobufVector clear() {
133 if (isEmpty()) {
134 return this;
135 }
136 cachedSize = -1;
137 bitField0_ = 0;
138 rows.clear();
139 return this;
140 }
141
142 @Override
143 public ProtobufVector clearQuick() {
144 if (isEmpty()) {
145 return this;
146 }
147 cachedSize = -1;
148 bitField0_ = 0;
149 rows.clear();
150 return this;
151 }
152
153 @Override
154 public boolean equals(Object o) {
155 if (o == this) {
156 return true;
157 }
158 if (!(o instanceof ProtobufVector)) {
159 return false;
160 }
161 ProtobufVector other = (ProtobufVector) o;
162 return bitField0_ == other.bitField0_
163 && (!hasRows() || rows.equals(other.rows));
164 }
165
166 @Override
167 public void writeTo(final ProtoSink output) throws IOException {
168 if ((bitField0_ & 0x00000001) != 0) {
169 for (int i = 0; i < rows.length(); i++) {
170 output.writeRawByte((byte) 9);
171 output.writeDoubleNoTag(rows.array()[i]);
172 }
173 }
174 }
175
176 @Override
177 protected int computeSerializedSize() {
178 int size = 0;
179 if ((bitField0_ & 0x00000001) != 0) {
180 size += (1 + 8) * rows.length();
181 }
182 return size;
183 }
184
185 @Override
186 @SuppressWarnings("fallthrough")
187 public ProtobufVector mergeFrom(final ProtoSource input) throws IOException {
188 // Enabled Fall-Through Optimization (QuickBuffers)
189 int tag = input.readTag();
190 while (true) {
191 switch (tag) {
192 case 10: {
193 // rows [packed=true]
194 input.readPackedDouble(rows);
195 bitField0_ |= 0x00000001;
196 tag = input.readTag();
197 if (tag != 0) {
198 break;
199 }
200 }
201 case 0: {
202 return this;
203 }
204 default: {
205 if (!input.skipField(tag)) {
206 return this;
207 }
208 tag = input.readTag();
209 break;
210 }
211 case 9: {
212 // rows [packed=false]
213 tag = input.readRepeatedDouble(rows, tag);
214 bitField0_ |= 0x00000001;
215 break;
216 }
217 }
218 }
219 }
220
221 @Override
222 public void writeTo(final JsonSink output) throws IOException {
223 output.beginObject();
224 if ((bitField0_ & 0x00000001) != 0) {
225 output.writeRepeatedDouble(FieldNames.rows, rows);
226 }
227 output.endObject();
228 }
229
230 @Override
231 public ProtobufVector mergeFrom(final JsonSource input) throws IOException {
232 if (!input.beginObject()) {
233 return this;
234 }
235 while (!input.isAtEnd()) {
236 switch (input.readFieldHash()) {
237 case 3506649: {
238 if (input.isAtField(FieldNames.rows)) {
239 if (!input.trySkipNullValue()) {
240 input.readRepeatedDouble(rows);
241 bitField0_ |= 0x00000001;
242 }
243 } else {
244 input.skipUnknownField();
245 }
246 break;
247 }
248 default: {
249 input.skipUnknownField();
250 break;
251 }
252 }
253 }
254 input.endObject();
255 return this;
256 }
257
258 @Override
259 public ProtobufVector clone() {
260 return new ProtobufVector().copyFrom(this);
261 }
262
263 @Override
264 public boolean isEmpty() {
265 return ((bitField0_) == 0);
266 }
267
268 public static ProtobufVector parseFrom(final byte[] data) throws InvalidProtocolBufferException {
269 return ProtoMessage.mergeFrom(new ProtobufVector(), data).checkInitialized();
270 }
271
272 public static ProtobufVector parseFrom(final ProtoSource input) throws IOException {
273 return ProtoMessage.mergeFrom(new ProtobufVector(), input).checkInitialized();
274 }
275
276 public static ProtobufVector parseFrom(final JsonSource input) throws IOException {
277 return ProtoMessage.mergeFrom(new ProtobufVector(), input).checkInitialized();
278 }
279
283 public static MessageFactory<ProtobufVector> getFactory() {
284 return ProtobufVectorFactory.INSTANCE;
285 }
286
290 public static Descriptors.Descriptor getDescriptor() {
291 return ProtobufWPIMathDescriptor.wpi_proto_ProtobufVector_descriptor;
292 }
293
294 private enum ProtobufVectorFactory implements MessageFactory<ProtobufVector> {
295 INSTANCE;
296
297 @Override
298 public ProtobufVector create() {
299 return ProtobufVector.newInstance();
300 }
301 }
302
306 static class FieldNames {
307 static final FieldName rows = FieldName.forField("rows");
308 }
309}
static MessageFactory< ProtobufVector > getFactory()
ProtobufVector addAllRows(final double... values)