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 ProtobufTranslation3d} 021 */ 022@SuppressWarnings("hiding") 023public final class ProtobufTranslation3d extends ProtoMessage<ProtobufTranslation3d> implements Cloneable { 024 private static final long serialVersionUID = 0L; 025 026 /** 027 * <code>optional double x = 1;</code> 028 */ 029 private double x; 030 031 /** 032 * <code>optional double y = 2;</code> 033 */ 034 private double y; 035 036 /** 037 * <code>optional double z = 3;</code> 038 */ 039 private double z; 040 041 private ProtobufTranslation3d() { 042 } 043 044 /** 045 * @return a new empty instance of {@code ProtobufTranslation3d} 046 */ 047 public static ProtobufTranslation3d newInstance() { 048 return new ProtobufTranslation3d(); 049 } 050 051 /** 052 * <code>optional double x = 1;</code> 053 * @return whether the x field is set 054 */ 055 public boolean hasX() { 056 return (bitField0_ & 0x00000001) != 0; 057 } 058 059 /** 060 * <code>optional double x = 1;</code> 061 * @return this 062 */ 063 public ProtobufTranslation3d clearX() { 064 bitField0_ &= ~0x00000001; 065 x = 0D; 066 return this; 067 } 068 069 /** 070 * <code>optional double x = 1;</code> 071 * @return the x 072 */ 073 public double getX() { 074 return x; 075 } 076 077 /** 078 * <code>optional double x = 1;</code> 079 * @param value the x to set 080 * @return this 081 */ 082 public ProtobufTranslation3d setX(final double value) { 083 bitField0_ |= 0x00000001; 084 x = value; 085 return this; 086 } 087 088 /** 089 * <code>optional double y = 2;</code> 090 * @return whether the y field is set 091 */ 092 public boolean hasY() { 093 return (bitField0_ & 0x00000002) != 0; 094 } 095 096 /** 097 * <code>optional double y = 2;</code> 098 * @return this 099 */ 100 public ProtobufTranslation3d clearY() { 101 bitField0_ &= ~0x00000002; 102 y = 0D; 103 return this; 104 } 105 106 /** 107 * <code>optional double y = 2;</code> 108 * @return the y 109 */ 110 public double getY() { 111 return y; 112 } 113 114 /** 115 * <code>optional double y = 2;</code> 116 * @param value the y to set 117 * @return this 118 */ 119 public ProtobufTranslation3d setY(final double value) { 120 bitField0_ |= 0x00000002; 121 y = value; 122 return this; 123 } 124 125 /** 126 * <code>optional double z = 3;</code> 127 * @return whether the z field is set 128 */ 129 public boolean hasZ() { 130 return (bitField0_ & 0x00000004) != 0; 131 } 132 133 /** 134 * <code>optional double z = 3;</code> 135 * @return this 136 */ 137 public ProtobufTranslation3d clearZ() { 138 bitField0_ &= ~0x00000004; 139 z = 0D; 140 return this; 141 } 142 143 /** 144 * <code>optional double z = 3;</code> 145 * @return the z 146 */ 147 public double getZ() { 148 return z; 149 } 150 151 /** 152 * <code>optional double z = 3;</code> 153 * @param value the z to set 154 * @return this 155 */ 156 public ProtobufTranslation3d setZ(final double value) { 157 bitField0_ |= 0x00000004; 158 z = value; 159 return this; 160 } 161 162 @Override 163 public ProtobufTranslation3d copyFrom(final ProtobufTranslation3d other) { 164 cachedSize = other.cachedSize; 165 if ((bitField0_ | other.bitField0_) != 0) { 166 bitField0_ = other.bitField0_; 167 x = other.x; 168 y = other.y; 169 z = other.z; 170 } 171 return this; 172 } 173 174 @Override 175 public ProtobufTranslation3d mergeFrom(final ProtobufTranslation3d other) { 176 if (other.isEmpty()) { 177 return this; 178 } 179 cachedSize = -1; 180 if (other.hasX()) { 181 setX(other.x); 182 } 183 if (other.hasY()) { 184 setY(other.y); 185 } 186 if (other.hasZ()) { 187 setZ(other.z); 188 } 189 return this; 190 } 191 192 @Override 193 public ProtobufTranslation3d clear() { 194 if (isEmpty()) { 195 return this; 196 } 197 cachedSize = -1; 198 bitField0_ = 0; 199 x = 0D; 200 y = 0D; 201 z = 0D; 202 return this; 203 } 204 205 @Override 206 public ProtobufTranslation3d 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 ProtobufTranslation3d)) { 221 return false; 222 } 223 ProtobufTranslation3d other = (ProtobufTranslation3d) o; 224 return bitField0_ == other.bitField0_ 225 && (!hasX() || ProtoUtil.isEqual(x, other.x)) 226 && (!hasY() || ProtoUtil.isEqual(y, other.y)) 227 && (!hasZ() || ProtoUtil.isEqual(z, other.z)); 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(x); 235 } 236 if ((bitField0_ & 0x00000002) != 0) { 237 output.writeRawByte((byte) 17); 238 output.writeDoubleNoTag(y); 239 } 240 if ((bitField0_ & 0x00000004) != 0) { 241 output.writeRawByte((byte) 25); 242 output.writeDoubleNoTag(z); 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 ProtobufTranslation3d 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 // x 270 x = input.readDouble(); 271 bitField0_ |= 0x00000001; 272 tag = input.readTag(); 273 if (tag != 17) { 274 break; 275 } 276 } 277 case 17: { 278 // y 279 y = input.readDouble(); 280 bitField0_ |= 0x00000002; 281 tag = input.readTag(); 282 if (tag != 25) { 283 break; 284 } 285 } 286 case 25: { 287 // z 288 z = 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.x, x); 314 } 315 if ((bitField0_ & 0x00000002) != 0) { 316 output.writeDouble(FieldNames.y, y); 317 } 318 if ((bitField0_ & 0x00000004) != 0) { 319 output.writeDouble(FieldNames.z, z); 320 } 321 output.endObject(); 322 } 323 324 @Override 325 public ProtobufTranslation3d mergeFrom(final JsonSource input) throws IOException { 326 if (!input.beginObject()) { 327 return this; 328 } 329 while (!input.isAtEnd()) { 330 switch (input.readFieldHash()) { 331 case 120: { 332 if (input.isAtField(FieldNames.x)) { 333 if (!input.trySkipNullValue()) { 334 x = input.readDouble(); 335 bitField0_ |= 0x00000001; 336 } 337 } else { 338 input.skipUnknownField(); 339 } 340 break; 341 } 342 case 121: { 343 if (input.isAtField(FieldNames.y)) { 344 if (!input.trySkipNullValue()) { 345 y = input.readDouble(); 346 bitField0_ |= 0x00000002; 347 } 348 } else { 349 input.skipUnknownField(); 350 } 351 break; 352 } 353 case 122: { 354 if (input.isAtField(FieldNames.z)) { 355 if (!input.trySkipNullValue()) { 356 z = 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 ProtobufTranslation3d clone() { 376 return new ProtobufTranslation3d().copyFrom(this); 377 } 378 379 @Override 380 public boolean isEmpty() { 381 return ((bitField0_) == 0); 382 } 383 384 public static ProtobufTranslation3d parseFrom(final byte[] data) throws 385 InvalidProtocolBufferException { 386 return ProtoMessage.mergeFrom(new ProtobufTranslation3d(), data).checkInitialized(); 387 } 388 389 public static ProtobufTranslation3d parseFrom(final ProtoSource input) throws IOException { 390 return ProtoMessage.mergeFrom(new ProtobufTranslation3d(), input).checkInitialized(); 391 } 392 393 public static ProtobufTranslation3d parseFrom(final JsonSource input) throws IOException { 394 return ProtoMessage.mergeFrom(new ProtobufTranslation3d(), input).checkInitialized(); 395 } 396 397 /** 398 * @return factory for creating ProtobufTranslation3d messages 399 */ 400 public static MessageFactory<ProtobufTranslation3d> getFactory() { 401 return ProtobufTranslation3dFactory.INSTANCE; 402 } 403 404 /** 405 * @return this type's descriptor. 406 */ 407 public static Descriptors.Descriptor getDescriptor() { 408 return ProtobufGeometry3dDescriptor.wpi_proto_ProtobufTranslation3d_descriptor; 409 } 410 411 private enum ProtobufTranslation3dFactory implements MessageFactory<ProtobufTranslation3d> { 412 INSTANCE; 413 414 @Override 415 public ProtobufTranslation3d create() { 416 return ProtobufTranslation3d.newInstance(); 417 } 418 } 419 420 /** 421 * Contains name constants used for serializing JSON 422 */ 423 static class FieldNames { 424 static final FieldName x = FieldName.forField("x"); 425 426 static final FieldName y = FieldName.forField("y"); 427 428 static final FieldName z = FieldName.forField("z"); 429 } 430}