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 ProtobufDifferentialDriveKinematics} 021 */ 022@SuppressWarnings("hiding") 023public final class ProtobufDifferentialDriveKinematics extends ProtoMessage<ProtobufDifferentialDriveKinematics> implements Cloneable { 024 private static final long serialVersionUID = 0L; 025 026 /** 027 * <code>optional double trackwidth = 1;</code> 028 */ 029 private double trackwidth; 030 031 private ProtobufDifferentialDriveKinematics() { 032 } 033 034 /** 035 * @return a new empty instance of {@code ProtobufDifferentialDriveKinematics} 036 */ 037 public static ProtobufDifferentialDriveKinematics newInstance() { 038 return new ProtobufDifferentialDriveKinematics(); 039 } 040 041 /** 042 * <code>optional double trackwidth = 1;</code> 043 * @return whether the trackwidth field is set 044 */ 045 public boolean hasTrackwidth() { 046 return (bitField0_ & 0x00000001) != 0; 047 } 048 049 /** 050 * <code>optional double trackwidth = 1;</code> 051 * @return this 052 */ 053 public ProtobufDifferentialDriveKinematics clearTrackwidth() { 054 bitField0_ &= ~0x00000001; 055 trackwidth = 0D; 056 return this; 057 } 058 059 /** 060 * <code>optional double trackwidth = 1;</code> 061 * @return the trackwidth 062 */ 063 public double getTrackwidth() { 064 return trackwidth; 065 } 066 067 /** 068 * <code>optional double trackwidth = 1;</code> 069 * @param value the trackwidth to set 070 * @return this 071 */ 072 public ProtobufDifferentialDriveKinematics setTrackwidth(final double value) { 073 bitField0_ |= 0x00000001; 074 trackwidth = value; 075 return this; 076 } 077 078 @Override 079 public ProtobufDifferentialDriveKinematics copyFrom( 080 final ProtobufDifferentialDriveKinematics other) { 081 cachedSize = other.cachedSize; 082 if ((bitField0_ | other.bitField0_) != 0) { 083 bitField0_ = other.bitField0_; 084 trackwidth = other.trackwidth; 085 } 086 return this; 087 } 088 089 @Override 090 public ProtobufDifferentialDriveKinematics mergeFrom( 091 final ProtobufDifferentialDriveKinematics other) { 092 if (other.isEmpty()) { 093 return this; 094 } 095 cachedSize = -1; 096 if (other.hasTrackwidth()) { 097 setTrackwidth(other.trackwidth); 098 } 099 return this; 100 } 101 102 @Override 103 public ProtobufDifferentialDriveKinematics clear() { 104 if (isEmpty()) { 105 return this; 106 } 107 cachedSize = -1; 108 bitField0_ = 0; 109 trackwidth = 0D; 110 return this; 111 } 112 113 @Override 114 public ProtobufDifferentialDriveKinematics clearQuick() { 115 if (isEmpty()) { 116 return this; 117 } 118 cachedSize = -1; 119 bitField0_ = 0; 120 return this; 121 } 122 123 @Override 124 public boolean equals(Object o) { 125 if (o == this) { 126 return true; 127 } 128 if (!(o instanceof ProtobufDifferentialDriveKinematics)) { 129 return false; 130 } 131 ProtobufDifferentialDriveKinematics other = (ProtobufDifferentialDriveKinematics) o; 132 return bitField0_ == other.bitField0_ 133 && (!hasTrackwidth() || ProtoUtil.isEqual(trackwidth, other.trackwidth)); 134 } 135 136 @Override 137 public void writeTo(final ProtoSink output) throws IOException { 138 if ((bitField0_ & 0x00000001) != 0) { 139 output.writeRawByte((byte) 9); 140 output.writeDoubleNoTag(trackwidth); 141 } 142 } 143 144 @Override 145 protected int computeSerializedSize() { 146 int size = 0; 147 if ((bitField0_ & 0x00000001) != 0) { 148 size += 9; 149 } 150 return size; 151 } 152 153 @Override 154 @SuppressWarnings("fallthrough") 155 public ProtobufDifferentialDriveKinematics mergeFrom(final ProtoSource input) throws IOException { 156 // Enabled Fall-Through Optimization (QuickBuffers) 157 int tag = input.readTag(); 158 while (true) { 159 switch (tag) { 160 case 9: { 161 // trackwidth 162 trackwidth = input.readDouble(); 163 bitField0_ |= 0x00000001; 164 tag = input.readTag(); 165 if (tag != 0) { 166 break; 167 } 168 } 169 case 0: { 170 return this; 171 } 172 default: { 173 if (!input.skipField(tag)) { 174 return this; 175 } 176 tag = input.readTag(); 177 break; 178 } 179 } 180 } 181 } 182 183 @Override 184 public void writeTo(final JsonSink output) throws IOException { 185 output.beginObject(); 186 if ((bitField0_ & 0x00000001) != 0) { 187 output.writeDouble(FieldNames.trackwidth, trackwidth); 188 } 189 output.endObject(); 190 } 191 192 @Override 193 public ProtobufDifferentialDriveKinematics mergeFrom(final JsonSource input) throws IOException { 194 if (!input.beginObject()) { 195 return this; 196 } 197 while (!input.isAtEnd()) { 198 switch (input.readFieldHash()) { 199 case 1181766491: { 200 if (input.isAtField(FieldNames.trackwidth)) { 201 if (!input.trySkipNullValue()) { 202 trackwidth = input.readDouble(); 203 bitField0_ |= 0x00000001; 204 } 205 } else { 206 input.skipUnknownField(); 207 } 208 break; 209 } 210 default: { 211 input.skipUnknownField(); 212 break; 213 } 214 } 215 } 216 input.endObject(); 217 return this; 218 } 219 220 @Override 221 public ProtobufDifferentialDriveKinematics clone() { 222 return new ProtobufDifferentialDriveKinematics().copyFrom(this); 223 } 224 225 @Override 226 public boolean isEmpty() { 227 return ((bitField0_) == 0); 228 } 229 230 public static ProtobufDifferentialDriveKinematics parseFrom(final byte[] data) throws 231 InvalidProtocolBufferException { 232 return ProtoMessage.mergeFrom(new ProtobufDifferentialDriveKinematics(), data).checkInitialized(); 233 } 234 235 public static ProtobufDifferentialDriveKinematics parseFrom(final ProtoSource input) throws 236 IOException { 237 return ProtoMessage.mergeFrom(new ProtobufDifferentialDriveKinematics(), input).checkInitialized(); 238 } 239 240 public static ProtobufDifferentialDriveKinematics parseFrom(final JsonSource input) throws 241 IOException { 242 return ProtoMessage.mergeFrom(new ProtobufDifferentialDriveKinematics(), input).checkInitialized(); 243 } 244 245 /** 246 * @return factory for creating ProtobufDifferentialDriveKinematics messages 247 */ 248 public static MessageFactory<ProtobufDifferentialDriveKinematics> getFactory() { 249 return ProtobufDifferentialDriveKinematicsFactory.INSTANCE; 250 } 251 252 /** 253 * @return this type's descriptor. 254 */ 255 public static Descriptors.Descriptor getDescriptor() { 256 return ProtobufKinematicsDescriptor.wpi_proto_ProtobufDifferentialDriveKinematics_descriptor; 257 } 258 259 private enum ProtobufDifferentialDriveKinematicsFactory implements MessageFactory<ProtobufDifferentialDriveKinematics> { 260 INSTANCE; 261 262 @Override 263 public ProtobufDifferentialDriveKinematics create() { 264 return ProtobufDifferentialDriveKinematics.newInstance(); 265 } 266 } 267 268 /** 269 * Contains name constants used for serializing JSON 270 */ 271 static class FieldNames { 272 static final FieldName trackwidth = FieldName.forField("trackwidth"); 273 } 274}