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 ProtobufTwist2d} 021 */ 022@SuppressWarnings("hiding") 023public final class ProtobufTwist2d extends ProtoMessage<ProtobufTwist2d> implements Cloneable { 024 private static final long serialVersionUID = 0L; 025 026 /** 027 * <code>optional double dx = 1;</code> 028 */ 029 private double dx; 030 031 /** 032 * <code>optional double dy = 2;</code> 033 */ 034 private double dy; 035 036 /** 037 * <code>optional double dtheta = 3;</code> 038 */ 039 private double dtheta; 040 041 private ProtobufTwist2d() { 042 } 043 044 /** 045 * @return a new empty instance of {@code ProtobufTwist2d} 046 */ 047 public static ProtobufTwist2d newInstance() { 048 return new ProtobufTwist2d(); 049 } 050 051 /** 052 * <code>optional double dx = 1;</code> 053 * @return whether the dx field is set 054 */ 055 public boolean hasDx() { 056 return (bitField0_ & 0x00000001) != 0; 057 } 058 059 /** 060 * <code>optional double dx = 1;</code> 061 * @return this 062 */ 063 public ProtobufTwist2d clearDx() { 064 bitField0_ &= ~0x00000001; 065 dx = 0D; 066 return this; 067 } 068 069 /** 070 * <code>optional double dx = 1;</code> 071 * @return the dx 072 */ 073 public double getDx() { 074 return dx; 075 } 076 077 /** 078 * <code>optional double dx = 1;</code> 079 * @param value the dx to set 080 * @return this 081 */ 082 public ProtobufTwist2d setDx(final double value) { 083 bitField0_ |= 0x00000001; 084 dx = value; 085 return this; 086 } 087 088 /** 089 * <code>optional double dy = 2;</code> 090 * @return whether the dy field is set 091 */ 092 public boolean hasDy() { 093 return (bitField0_ & 0x00000002) != 0; 094 } 095 096 /** 097 * <code>optional double dy = 2;</code> 098 * @return this 099 */ 100 public ProtobufTwist2d clearDy() { 101 bitField0_ &= ~0x00000002; 102 dy = 0D; 103 return this; 104 } 105 106 /** 107 * <code>optional double dy = 2;</code> 108 * @return the dy 109 */ 110 public double getDy() { 111 return dy; 112 } 113 114 /** 115 * <code>optional double dy = 2;</code> 116 * @param value the dy to set 117 * @return this 118 */ 119 public ProtobufTwist2d setDy(final double value) { 120 bitField0_ |= 0x00000002; 121 dy = value; 122 return this; 123 } 124 125 /** 126 * <code>optional double dtheta = 3;</code> 127 * @return whether the dtheta field is set 128 */ 129 public boolean hasDtheta() { 130 return (bitField0_ & 0x00000004) != 0; 131 } 132 133 /** 134 * <code>optional double dtheta = 3;</code> 135 * @return this 136 */ 137 public ProtobufTwist2d clearDtheta() { 138 bitField0_ &= ~0x00000004; 139 dtheta = 0D; 140 return this; 141 } 142 143 /** 144 * <code>optional double dtheta = 3;</code> 145 * @return the dtheta 146 */ 147 public double getDtheta() { 148 return dtheta; 149 } 150 151 /** 152 * <code>optional double dtheta = 3;</code> 153 * @param value the dtheta to set 154 * @return this 155 */ 156 public ProtobufTwist2d setDtheta(final double value) { 157 bitField0_ |= 0x00000004; 158 dtheta = value; 159 return this; 160 } 161 162 @Override 163 public ProtobufTwist2d copyFrom(final ProtobufTwist2d other) { 164 cachedSize = other.cachedSize; 165 if ((bitField0_ | other.bitField0_) != 0) { 166 bitField0_ = other.bitField0_; 167 dx = other.dx; 168 dy = other.dy; 169 dtheta = other.dtheta; 170 } 171 return this; 172 } 173 174 @Override 175 public ProtobufTwist2d mergeFrom(final ProtobufTwist2d other) { 176 if (other.isEmpty()) { 177 return this; 178 } 179 cachedSize = -1; 180 if (other.hasDx()) { 181 setDx(other.dx); 182 } 183 if (other.hasDy()) { 184 setDy(other.dy); 185 } 186 if (other.hasDtheta()) { 187 setDtheta(other.dtheta); 188 } 189 return this; 190 } 191 192 @Override 193 public ProtobufTwist2d clear() { 194 if (isEmpty()) { 195 return this; 196 } 197 cachedSize = -1; 198 bitField0_ = 0; 199 dx = 0D; 200 dy = 0D; 201 dtheta = 0D; 202 return this; 203 } 204 205 @Override 206 public ProtobufTwist2d clearQuick() { 207 if (isEmpty()) { 208 return this; 209 } 210 cachedSize = -1; 211 bitField0_ = 0; 212 return this; 213 } 214 215 @Override 216 public boolean equals(Object o) { 217 if (o == this) { 218 return true; 219 } 220 if (!(o instanceof ProtobufTwist2d)) { 221 return false; 222 } 223 ProtobufTwist2d other = (ProtobufTwist2d) o; 224 return bitField0_ == other.bitField0_ 225 && (!hasDx() || ProtoUtil.isEqual(dx, other.dx)) 226 && (!hasDy() || ProtoUtil.isEqual(dy, other.dy)) 227 && (!hasDtheta() || ProtoUtil.isEqual(dtheta, other.dtheta)); 228 } 229 230 @Override 231 public void writeTo(final ProtoSink output) throws IOException { 232 if ((bitField0_ & 0x00000001) != 0) { 233 output.writeRawByte((byte) 9); 234 output.writeDoubleNoTag(dx); 235 } 236 if ((bitField0_ & 0x00000002) != 0) { 237 output.writeRawByte((byte) 17); 238 output.writeDoubleNoTag(dy); 239 } 240 if ((bitField0_ & 0x00000004) != 0) { 241 output.writeRawByte((byte) 25); 242 output.writeDoubleNoTag(dtheta); 243 } 244 } 245 246 @Override 247 protected int computeSerializedSize() { 248 int size = 0; 249 if ((bitField0_ & 0x00000001) != 0) { 250 size += 9; 251 } 252 if ((bitField0_ & 0x00000002) != 0) { 253 size += 9; 254 } 255 if ((bitField0_ & 0x00000004) != 0) { 256 size += 9; 257 } 258 return size; 259 } 260 261 @Override 262 @SuppressWarnings("fallthrough") 263 public ProtobufTwist2d mergeFrom(final ProtoSource input) throws IOException { 264 // Enabled Fall-Through Optimization (QuickBuffers) 265 int tag = input.readTag(); 266 while (true) { 267 switch (tag) { 268 case 9: { 269 // dx 270 dx = input.readDouble(); 271 bitField0_ |= 0x00000001; 272 tag = input.readTag(); 273 if (tag != 17) { 274 break; 275 } 276 } 277 case 17: { 278 // dy 279 dy = input.readDouble(); 280 bitField0_ |= 0x00000002; 281 tag = input.readTag(); 282 if (tag != 25) { 283 break; 284 } 285 } 286 case 25: { 287 // dtheta 288 dtheta = input.readDouble(); 289 bitField0_ |= 0x00000004; 290 tag = input.readTag(); 291 if (tag != 0) { 292 break; 293 } 294 } 295 case 0: { 296 return this; 297 } 298 default: { 299 if (!input.skipField(tag)) { 300 return this; 301 } 302 tag = input.readTag(); 303 break; 304 } 305 } 306 } 307 } 308 309 @Override 310 public void writeTo(final JsonSink output) throws IOException { 311 output.beginObject(); 312 if ((bitField0_ & 0x00000001) != 0) { 313 output.writeDouble(FieldNames.dx, dx); 314 } 315 if ((bitField0_ & 0x00000002) != 0) { 316 output.writeDouble(FieldNames.dy, dy); 317 } 318 if ((bitField0_ & 0x00000004) != 0) { 319 output.writeDouble(FieldNames.dtheta, dtheta); 320 } 321 output.endObject(); 322 } 323 324 @Override 325 public ProtobufTwist2d mergeFrom(final JsonSource input) throws IOException { 326 if (!input.beginObject()) { 327 return this; 328 } 329 while (!input.isAtEnd()) { 330 switch (input.readFieldHash()) { 331 case 3220: { 332 if (input.isAtField(FieldNames.dx)) { 333 if (!input.trySkipNullValue()) { 334 dx = input.readDouble(); 335 bitField0_ |= 0x00000001; 336 } 337 } else { 338 input.skipUnknownField(); 339 } 340 break; 341 } 342 case 3221: { 343 if (input.isAtField(FieldNames.dy)) { 344 if (!input.trySkipNullValue()) { 345 dy = input.readDouble(); 346 bitField0_ |= 0x00000002; 347 } 348 } else { 349 input.skipUnknownField(); 350 } 351 break; 352 } 353 case -1321724742: { 354 if (input.isAtField(FieldNames.dtheta)) { 355 if (!input.trySkipNullValue()) { 356 dtheta = input.readDouble(); 357 bitField0_ |= 0x00000004; 358 } 359 } else { 360 input.skipUnknownField(); 361 } 362 break; 363 } 364 default: { 365 input.skipUnknownField(); 366 break; 367 } 368 } 369 } 370 input.endObject(); 371 return this; 372 } 373 374 @Override 375 public ProtobufTwist2d clone() { 376 return new ProtobufTwist2d().copyFrom(this); 377 } 378 379 @Override 380 public boolean isEmpty() { 381 return ((bitField0_) == 0); 382 } 383 384 public static ProtobufTwist2d parseFrom(final byte[] data) throws InvalidProtocolBufferException { 385 return ProtoMessage.mergeFrom(new ProtobufTwist2d(), data).checkInitialized(); 386 } 387 388 public static ProtobufTwist2d parseFrom(final ProtoSource input) throws IOException { 389 return ProtoMessage.mergeFrom(new ProtobufTwist2d(), input).checkInitialized(); 390 } 391 392 public static ProtobufTwist2d parseFrom(final JsonSource input) throws IOException { 393 return ProtoMessage.mergeFrom(new ProtobufTwist2d(), input).checkInitialized(); 394 } 395 396 /** 397 * @return factory for creating ProtobufTwist2d messages 398 */ 399 public static MessageFactory<ProtobufTwist2d> getFactory() { 400 return ProtobufTwist2dFactory.INSTANCE; 401 } 402 403 /** 404 * @return this type's descriptor. 405 */ 406 public static Descriptors.Descriptor getDescriptor() { 407 return ProtobufGeometry2dDescriptor.wpi_proto_ProtobufTwist2d_descriptor; 408 } 409 410 private enum ProtobufTwist2dFactory implements MessageFactory<ProtobufTwist2d> { 411 INSTANCE; 412 413 @Override 414 public ProtobufTwist2d create() { 415 return ProtobufTwist2d.newInstance(); 416 } 417 } 418 419 /** 420 * Contains name constants used for serializing JSON 421 */ 422 static class FieldNames { 423 static final FieldName dx = FieldName.forField("dx"); 424 425 static final FieldName dy = FieldName.forField("dy"); 426 427 static final FieldName dtheta = FieldName.forField("dtheta"); 428 } 429}