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 ProtobufTrajectoryState} 021 */ 022@SuppressWarnings("hiding") 023public final class ProtobufTrajectoryState extends ProtoMessage<ProtobufTrajectoryState> implements Cloneable { 024 private static final long serialVersionUID = 0L; 025 026 /** 027 * <code>optional double time = 1;</code> 028 */ 029 private double time; 030 031 /** 032 * <code>optional double velocity = 2;</code> 033 */ 034 private double velocity; 035 036 /** 037 * <code>optional double acceleration = 3;</code> 038 */ 039 private double acceleration; 040 041 /** 042 * <code>optional double curvature = 5;</code> 043 */ 044 private double curvature; 045 046 /** 047 * <code>optional .wpi.proto.ProtobufPose2d pose = 4;</code> 048 */ 049 private final ProtobufPose2d pose = ProtobufPose2d.newInstance(); 050 051 private ProtobufTrajectoryState() { 052 } 053 054 /** 055 * @return a new empty instance of {@code ProtobufTrajectoryState} 056 */ 057 public static ProtobufTrajectoryState newInstance() { 058 return new ProtobufTrajectoryState(); 059 } 060 061 /** 062 * <code>optional double time = 1;</code> 063 * @return whether the time field is set 064 */ 065 public boolean hasTime() { 066 return (bitField0_ & 0x00000001) != 0; 067 } 068 069 /** 070 * <code>optional double time = 1;</code> 071 * @return this 072 */ 073 public ProtobufTrajectoryState clearTime() { 074 bitField0_ &= ~0x00000001; 075 time = 0D; 076 return this; 077 } 078 079 /** 080 * <code>optional double time = 1;</code> 081 * @return the time 082 */ 083 public double getTime() { 084 return time; 085 } 086 087 /** 088 * <code>optional double time = 1;</code> 089 * @param value the time to set 090 * @return this 091 */ 092 public ProtobufTrajectoryState setTime(final double value) { 093 bitField0_ |= 0x00000001; 094 time = value; 095 return this; 096 } 097 098 /** 099 * <code>optional double velocity = 2;</code> 100 * @return whether the velocity field is set 101 */ 102 public boolean hasVelocity() { 103 return (bitField0_ & 0x00000002) != 0; 104 } 105 106 /** 107 * <code>optional double velocity = 2;</code> 108 * @return this 109 */ 110 public ProtobufTrajectoryState clearVelocity() { 111 bitField0_ &= ~0x00000002; 112 velocity = 0D; 113 return this; 114 } 115 116 /** 117 * <code>optional double velocity = 2;</code> 118 * @return the velocity 119 */ 120 public double getVelocity() { 121 return velocity; 122 } 123 124 /** 125 * <code>optional double velocity = 2;</code> 126 * @param value the velocity to set 127 * @return this 128 */ 129 public ProtobufTrajectoryState setVelocity(final double value) { 130 bitField0_ |= 0x00000002; 131 velocity = value; 132 return this; 133 } 134 135 /** 136 * <code>optional double acceleration = 3;</code> 137 * @return whether the acceleration field is set 138 */ 139 public boolean hasAcceleration() { 140 return (bitField0_ & 0x00000004) != 0; 141 } 142 143 /** 144 * <code>optional double acceleration = 3;</code> 145 * @return this 146 */ 147 public ProtobufTrajectoryState clearAcceleration() { 148 bitField0_ &= ~0x00000004; 149 acceleration = 0D; 150 return this; 151 } 152 153 /** 154 * <code>optional double acceleration = 3;</code> 155 * @return the acceleration 156 */ 157 public double getAcceleration() { 158 return acceleration; 159 } 160 161 /** 162 * <code>optional double acceleration = 3;</code> 163 * @param value the acceleration to set 164 * @return this 165 */ 166 public ProtobufTrajectoryState setAcceleration(final double value) { 167 bitField0_ |= 0x00000004; 168 acceleration = value; 169 return this; 170 } 171 172 /** 173 * <code>optional double curvature = 5;</code> 174 * @return whether the curvature field is set 175 */ 176 public boolean hasCurvature() { 177 return (bitField0_ & 0x00000008) != 0; 178 } 179 180 /** 181 * <code>optional double curvature = 5;</code> 182 * @return this 183 */ 184 public ProtobufTrajectoryState clearCurvature() { 185 bitField0_ &= ~0x00000008; 186 curvature = 0D; 187 return this; 188 } 189 190 /** 191 * <code>optional double curvature = 5;</code> 192 * @return the curvature 193 */ 194 public double getCurvature() { 195 return curvature; 196 } 197 198 /** 199 * <code>optional double curvature = 5;</code> 200 * @param value the curvature to set 201 * @return this 202 */ 203 public ProtobufTrajectoryState setCurvature(final double value) { 204 bitField0_ |= 0x00000008; 205 curvature = value; 206 return this; 207 } 208 209 /** 210 * <code>optional .wpi.proto.ProtobufPose2d pose = 4;</code> 211 * @return whether the pose field is set 212 */ 213 public boolean hasPose() { 214 return (bitField0_ & 0x00000010) != 0; 215 } 216 217 /** 218 * <code>optional .wpi.proto.ProtobufPose2d pose = 4;</code> 219 * @return this 220 */ 221 public ProtobufTrajectoryState clearPose() { 222 bitField0_ &= ~0x00000010; 223 pose.clear(); 224 return this; 225 } 226 227 /** 228 * <code>optional .wpi.proto.ProtobufPose2d pose = 4;</code> 229 * 230 * This method returns the internal storage object without modifying any has state. 231 * The returned object should not be modified and be treated as read-only. 232 * 233 * Use {@link #getMutablePose()} if you want to modify it. 234 * 235 * @return internal storage object for reading 236 */ 237 public ProtobufPose2d getPose() { 238 return pose; 239 } 240 241 /** 242 * <code>optional .wpi.proto.ProtobufPose2d pose = 4;</code> 243 * 244 * This method returns the internal storage object and sets the corresponding 245 * has state. The returned object will become part of this message and its 246 * contents may be modified as long as the has state is not cleared. 247 * 248 * @return internal storage object for modifications 249 */ 250 public ProtobufPose2d getMutablePose() { 251 bitField0_ |= 0x00000010; 252 return pose; 253 } 254 255 /** 256 * <code>optional .wpi.proto.ProtobufPose2d pose = 4;</code> 257 * @param value the pose to set 258 * @return this 259 */ 260 public ProtobufTrajectoryState setPose(final ProtobufPose2d value) { 261 bitField0_ |= 0x00000010; 262 pose.copyFrom(value); 263 return this; 264 } 265 266 @Override 267 public ProtobufTrajectoryState copyFrom(final ProtobufTrajectoryState other) { 268 cachedSize = other.cachedSize; 269 if ((bitField0_ | other.bitField0_) != 0) { 270 bitField0_ = other.bitField0_; 271 time = other.time; 272 velocity = other.velocity; 273 acceleration = other.acceleration; 274 curvature = other.curvature; 275 pose.copyFrom(other.pose); 276 } 277 return this; 278 } 279 280 @Override 281 public ProtobufTrajectoryState mergeFrom(final ProtobufTrajectoryState other) { 282 if (other.isEmpty()) { 283 return this; 284 } 285 cachedSize = -1; 286 if (other.hasTime()) { 287 setTime(other.time); 288 } 289 if (other.hasVelocity()) { 290 setVelocity(other.velocity); 291 } 292 if (other.hasAcceleration()) { 293 setAcceleration(other.acceleration); 294 } 295 if (other.hasCurvature()) { 296 setCurvature(other.curvature); 297 } 298 if (other.hasPose()) { 299 getMutablePose().mergeFrom(other.pose); 300 } 301 return this; 302 } 303 304 @Override 305 public ProtobufTrajectoryState clear() { 306 if (isEmpty()) { 307 return this; 308 } 309 cachedSize = -1; 310 bitField0_ = 0; 311 time = 0D; 312 velocity = 0D; 313 acceleration = 0D; 314 curvature = 0D; 315 pose.clear(); 316 return this; 317 } 318 319 @Override 320 public ProtobufTrajectoryState clearQuick() { 321 if (isEmpty()) { 322 return this; 323 } 324 cachedSize = -1; 325 bitField0_ = 0; 326 pose.clearQuick(); 327 return this; 328 } 329 330 @Override 331 public boolean equals(Object o) { 332 if (o == this) { 333 return true; 334 } 335 if (!(o instanceof ProtobufTrajectoryState)) { 336 return false; 337 } 338 ProtobufTrajectoryState other = (ProtobufTrajectoryState) o; 339 return bitField0_ == other.bitField0_ 340 && (!hasTime() || ProtoUtil.isEqual(time, other.time)) 341 && (!hasVelocity() || ProtoUtil.isEqual(velocity, other.velocity)) 342 && (!hasAcceleration() || ProtoUtil.isEqual(acceleration, other.acceleration)) 343 && (!hasCurvature() || ProtoUtil.isEqual(curvature, other.curvature)) 344 && (!hasPose() || pose.equals(other.pose)); 345 } 346 347 @Override 348 public void writeTo(final ProtoSink output) throws IOException { 349 if ((bitField0_ & 0x00000001) != 0) { 350 output.writeRawByte((byte) 9); 351 output.writeDoubleNoTag(time); 352 } 353 if ((bitField0_ & 0x00000002) != 0) { 354 output.writeRawByte((byte) 17); 355 output.writeDoubleNoTag(velocity); 356 } 357 if ((bitField0_ & 0x00000004) != 0) { 358 output.writeRawByte((byte) 25); 359 output.writeDoubleNoTag(acceleration); 360 } 361 if ((bitField0_ & 0x00000008) != 0) { 362 output.writeRawByte((byte) 41); 363 output.writeDoubleNoTag(curvature); 364 } 365 if ((bitField0_ & 0x00000010) != 0) { 366 output.writeRawByte((byte) 34); 367 output.writeMessageNoTag(pose); 368 } 369 } 370 371 @Override 372 protected int computeSerializedSize() { 373 int size = 0; 374 if ((bitField0_ & 0x00000001) != 0) { 375 size += 9; 376 } 377 if ((bitField0_ & 0x00000002) != 0) { 378 size += 9; 379 } 380 if ((bitField0_ & 0x00000004) != 0) { 381 size += 9; 382 } 383 if ((bitField0_ & 0x00000008) != 0) { 384 size += 9; 385 } 386 if ((bitField0_ & 0x00000010) != 0) { 387 size += 1 + ProtoSink.computeMessageSizeNoTag(pose); 388 } 389 return size; 390 } 391 392 @Override 393 @SuppressWarnings("fallthrough") 394 public ProtobufTrajectoryState mergeFrom(final ProtoSource input) throws IOException { 395 // Enabled Fall-Through Optimization (QuickBuffers) 396 int tag = input.readTag(); 397 while (true) { 398 switch (tag) { 399 case 9: { 400 // time 401 time = input.readDouble(); 402 bitField0_ |= 0x00000001; 403 tag = input.readTag(); 404 if (tag != 17) { 405 break; 406 } 407 } 408 case 17: { 409 // velocity 410 velocity = input.readDouble(); 411 bitField0_ |= 0x00000002; 412 tag = input.readTag(); 413 if (tag != 25) { 414 break; 415 } 416 } 417 case 25: { 418 // acceleration 419 acceleration = input.readDouble(); 420 bitField0_ |= 0x00000004; 421 tag = input.readTag(); 422 if (tag != 41) { 423 break; 424 } 425 } 426 case 41: { 427 // curvature 428 curvature = input.readDouble(); 429 bitField0_ |= 0x00000008; 430 tag = input.readTag(); 431 if (tag != 34) { 432 break; 433 } 434 } 435 case 34: { 436 // pose 437 input.readMessage(pose); 438 bitField0_ |= 0x00000010; 439 tag = input.readTag(); 440 if (tag != 0) { 441 break; 442 } 443 } 444 case 0: { 445 return this; 446 } 447 default: { 448 if (!input.skipField(tag)) { 449 return this; 450 } 451 tag = input.readTag(); 452 break; 453 } 454 } 455 } 456 } 457 458 @Override 459 public void writeTo(final JsonSink output) throws IOException { 460 output.beginObject(); 461 if ((bitField0_ & 0x00000001) != 0) { 462 output.writeDouble(FieldNames.time, time); 463 } 464 if ((bitField0_ & 0x00000002) != 0) { 465 output.writeDouble(FieldNames.velocity, velocity); 466 } 467 if ((bitField0_ & 0x00000004) != 0) { 468 output.writeDouble(FieldNames.acceleration, acceleration); 469 } 470 if ((bitField0_ & 0x00000008) != 0) { 471 output.writeDouble(FieldNames.curvature, curvature); 472 } 473 if ((bitField0_ & 0x00000010) != 0) { 474 output.writeMessage(FieldNames.pose, pose); 475 } 476 output.endObject(); 477 } 478 479 @Override 480 public ProtobufTrajectoryState mergeFrom(final JsonSource input) throws IOException { 481 if (!input.beginObject()) { 482 return this; 483 } 484 while (!input.isAtEnd()) { 485 switch (input.readFieldHash()) { 486 case 3560141: { 487 if (input.isAtField(FieldNames.time)) { 488 if (!input.trySkipNullValue()) { 489 time = input.readDouble(); 490 bitField0_ |= 0x00000001; 491 } 492 } else { 493 input.skipUnknownField(); 494 } 495 break; 496 } 497 case 2134260957: { 498 if (input.isAtField(FieldNames.velocity)) { 499 if (!input.trySkipNullValue()) { 500 velocity = input.readDouble(); 501 bitField0_ |= 0x00000002; 502 } 503 } else { 504 input.skipUnknownField(); 505 } 506 break; 507 } 508 case -267299712: { 509 if (input.isAtField(FieldNames.acceleration)) { 510 if (!input.trySkipNullValue()) { 511 acceleration = input.readDouble(); 512 bitField0_ |= 0x00000004; 513 } 514 } else { 515 input.skipUnknownField(); 516 } 517 break; 518 } 519 case 768611295: { 520 if (input.isAtField(FieldNames.curvature)) { 521 if (!input.trySkipNullValue()) { 522 curvature = input.readDouble(); 523 bitField0_ |= 0x00000008; 524 } 525 } else { 526 input.skipUnknownField(); 527 } 528 break; 529 } 530 case 3446929: { 531 if (input.isAtField(FieldNames.pose)) { 532 if (!input.trySkipNullValue()) { 533 input.readMessage(pose); 534 bitField0_ |= 0x00000010; 535 } 536 } else { 537 input.skipUnknownField(); 538 } 539 break; 540 } 541 default: { 542 input.skipUnknownField(); 543 break; 544 } 545 } 546 } 547 input.endObject(); 548 return this; 549 } 550 551 @Override 552 public ProtobufTrajectoryState clone() { 553 return new ProtobufTrajectoryState().copyFrom(this); 554 } 555 556 @Override 557 public boolean isEmpty() { 558 return ((bitField0_) == 0); 559 } 560 561 public static ProtobufTrajectoryState parseFrom(final byte[] data) throws 562 InvalidProtocolBufferException { 563 return ProtoMessage.mergeFrom(new ProtobufTrajectoryState(), data).checkInitialized(); 564 } 565 566 public static ProtobufTrajectoryState parseFrom(final ProtoSource input) throws IOException { 567 return ProtoMessage.mergeFrom(new ProtobufTrajectoryState(), input).checkInitialized(); 568 } 569 570 public static ProtobufTrajectoryState parseFrom(final JsonSource input) throws IOException { 571 return ProtoMessage.mergeFrom(new ProtobufTrajectoryState(), input).checkInitialized(); 572 } 573 574 /** 575 * @return factory for creating ProtobufTrajectoryState messages 576 */ 577 public static MessageFactory<ProtobufTrajectoryState> getFactory() { 578 return ProtobufTrajectoryStateFactory.INSTANCE; 579 } 580 581 /** 582 * @return this type's descriptor. 583 */ 584 public static Descriptors.Descriptor getDescriptor() { 585 return ProtobufTrajectoryDescriptor.wpi_proto_ProtobufTrajectoryState_descriptor; 586 } 587 588 private enum ProtobufTrajectoryStateFactory implements MessageFactory<ProtobufTrajectoryState> { 589 INSTANCE; 590 591 @Override 592 public ProtobufTrajectoryState create() { 593 return ProtobufTrajectoryState.newInstance(); 594 } 595 } 596 597 /** 598 * Contains name constants used for serializing JSON 599 */ 600 static class FieldNames { 601 static final FieldName time = FieldName.forField("time"); 602 603 static final FieldName velocity = FieldName.forField("velocity"); 604 605 static final FieldName acceleration = FieldName.forField("acceleration"); 606 607 static final FieldName curvature = FieldName.forField("curvature"); 608 609 static final FieldName pose = FieldName.forField("pose"); 610 } 611}