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.RepeatedDouble; 018 019/** 020 * Protobuf type {@code ProtobufVector} 021 */ 022@SuppressWarnings("hiding") 023public final class ProtobufVector extends ProtoMessage<ProtobufVector> implements Cloneable { 024 private static final long serialVersionUID = 0L; 025 026 /** 027 * <code>repeated double rows = 1;</code> 028 */ 029 private final RepeatedDouble rows = RepeatedDouble.newEmptyInstance(); 030 031 private ProtobufVector() { 032 } 033 034 /** 035 * @return a new empty instance of {@code ProtobufVector} 036 */ 037 public static ProtobufVector newInstance() { 038 return new ProtobufVector(); 039 } 040 041 /** 042 * <code>repeated double rows = 1;</code> 043 * @return whether the rows field is set 044 */ 045 public boolean hasRows() { 046 return (bitField0_ & 0x00000001) != 0; 047 } 048 049 /** 050 * <code>repeated double rows = 1;</code> 051 * @return this 052 */ 053 public ProtobufVector clearRows() { 054 bitField0_ &= ~0x00000001; 055 rows.clear(); 056 return this; 057 } 058 059 /** 060 * <code>repeated double rows = 1;</code> 061 * 062 * This method returns the internal storage object without modifying any has state. 063 * The returned object should not be modified and be treated as read-only. 064 * 065 * Use {@link #getMutableRows()} if you want to modify it. 066 * 067 * @return internal storage object for reading 068 */ 069 public RepeatedDouble getRows() { 070 return rows; 071 } 072 073 /** 074 * <code>repeated double rows = 1;</code> 075 * 076 * This method returns the internal storage object and sets the corresponding 077 * has state. The returned object will become part of this message and its 078 * contents may be modified as long as the has state is not cleared. 079 * 080 * @return internal storage object for modifications 081 */ 082 public RepeatedDouble getMutableRows() { 083 bitField0_ |= 0x00000001; 084 return rows; 085 } 086 087 /** 088 * <code>repeated double rows = 1;</code> 089 * @param value the rows to add 090 * @return this 091 */ 092 public ProtobufVector addRows(final double value) { 093 bitField0_ |= 0x00000001; 094 rows.add(value); 095 return this; 096 } 097 098 /** 099 * <code>repeated double rows = 1;</code> 100 * @param values the rows to add 101 * @return this 102 */ 103 public ProtobufVector addAllRows(final double... values) { 104 bitField0_ |= 0x00000001; 105 rows.addAll(values); 106 return this; 107 } 108 109 @Override 110 public ProtobufVector copyFrom(final ProtobufVector other) { 111 cachedSize = other.cachedSize; 112 if ((bitField0_ | other.bitField0_) != 0) { 113 bitField0_ = other.bitField0_; 114 rows.copyFrom(other.rows); 115 } 116 return this; 117 } 118 119 @Override 120 public ProtobufVector mergeFrom(final ProtobufVector other) { 121 if (other.isEmpty()) { 122 return this; 123 } 124 cachedSize = -1; 125 if (other.hasRows()) { 126 getMutableRows().addAll(other.rows); 127 } 128 return this; 129 } 130 131 @Override 132 public ProtobufVector clear() { 133 if (isEmpty()) { 134 return this; 135 } 136 cachedSize = -1; 137 bitField0_ = 0; 138 rows.clear(); 139 return this; 140 } 141 142 @Override 143 public ProtobufVector clearQuick() { 144 if (isEmpty()) { 145 return this; 146 } 147 cachedSize = -1; 148 bitField0_ = 0; 149 rows.clear(); 150 return this; 151 } 152 153 @Override 154 public boolean equals(Object o) { 155 if (o == this) { 156 return true; 157 } 158 if (!(o instanceof ProtobufVector)) { 159 return false; 160 } 161 ProtobufVector other = (ProtobufVector) o; 162 return bitField0_ == other.bitField0_ 163 && (!hasRows() || rows.equals(other.rows)); 164 } 165 166 @Override 167 public void writeTo(final ProtoSink output) throws IOException { 168 if ((bitField0_ & 0x00000001) != 0) { 169 for (int i = 0; i < rows.length(); i++) { 170 output.writeRawByte((byte) 9); 171 output.writeDoubleNoTag(rows.array()[i]); 172 } 173 } 174 } 175 176 @Override 177 protected int computeSerializedSize() { 178 int size = 0; 179 if ((bitField0_ & 0x00000001) != 0) { 180 size += (1 + 8) * rows.length(); 181 } 182 return size; 183 } 184 185 @Override 186 @SuppressWarnings("fallthrough") 187 public ProtobufVector mergeFrom(final ProtoSource input) throws IOException { 188 // Enabled Fall-Through Optimization (QuickBuffers) 189 int tag = input.readTag(); 190 while (true) { 191 switch (tag) { 192 case 10: { 193 // rows [packed=true] 194 input.readPackedDouble(rows); 195 bitField0_ |= 0x00000001; 196 tag = input.readTag(); 197 if (tag != 0) { 198 break; 199 } 200 } 201 case 0: { 202 return this; 203 } 204 default: { 205 if (!input.skipField(tag)) { 206 return this; 207 } 208 tag = input.readTag(); 209 break; 210 } 211 case 9: { 212 // rows [packed=false] 213 tag = input.readRepeatedDouble(rows, tag); 214 bitField0_ |= 0x00000001; 215 break; 216 } 217 } 218 } 219 } 220 221 @Override 222 public void writeTo(final JsonSink output) throws IOException { 223 output.beginObject(); 224 if ((bitField0_ & 0x00000001) != 0) { 225 output.writeRepeatedDouble(FieldNames.rows, rows); 226 } 227 output.endObject(); 228 } 229 230 @Override 231 public ProtobufVector mergeFrom(final JsonSource input) throws IOException { 232 if (!input.beginObject()) { 233 return this; 234 } 235 while (!input.isAtEnd()) { 236 switch (input.readFieldHash()) { 237 case 3506649: { 238 if (input.isAtField(FieldNames.rows)) { 239 if (!input.trySkipNullValue()) { 240 input.readRepeatedDouble(rows); 241 bitField0_ |= 0x00000001; 242 } 243 } else { 244 input.skipUnknownField(); 245 } 246 break; 247 } 248 default: { 249 input.skipUnknownField(); 250 break; 251 } 252 } 253 } 254 input.endObject(); 255 return this; 256 } 257 258 @Override 259 public ProtobufVector clone() { 260 return new ProtobufVector().copyFrom(this); 261 } 262 263 @Override 264 public boolean isEmpty() { 265 return ((bitField0_) == 0); 266 } 267 268 public static ProtobufVector parseFrom(final byte[] data) throws InvalidProtocolBufferException { 269 return ProtoMessage.mergeFrom(new ProtobufVector(), data).checkInitialized(); 270 } 271 272 public static ProtobufVector parseFrom(final ProtoSource input) throws IOException { 273 return ProtoMessage.mergeFrom(new ProtobufVector(), input).checkInitialized(); 274 } 275 276 public static ProtobufVector parseFrom(final JsonSource input) throws IOException { 277 return ProtoMessage.mergeFrom(new ProtobufVector(), input).checkInitialized(); 278 } 279 280 /** 281 * @return factory for creating ProtobufVector messages 282 */ 283 public static MessageFactory<ProtobufVector> getFactory() { 284 return ProtobufVectorFactory.INSTANCE; 285 } 286 287 /** 288 * @return this type's descriptor. 289 */ 290 public static Descriptors.Descriptor getDescriptor() { 291 return ProtobufWPIMathDescriptor.wpi_proto_ProtobufVector_descriptor; 292 } 293 294 private enum ProtobufVectorFactory implements MessageFactory<ProtobufVector> { 295 INSTANCE; 296 297 @Override 298 public ProtobufVector create() { 299 return ProtobufVector.newInstance(); 300 } 301 } 302 303 /** 304 * Contains name constants used for serializing JSON 305 */ 306 static class FieldNames { 307 static final FieldName rows = FieldName.forField("rows"); 308 } 309}