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