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