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 ProtobufCubicHermiteSpline}
021 */
022@SuppressWarnings("hiding")
023public final class ProtobufCubicHermiteSpline extends ProtoMessage<ProtobufCubicHermiteSpline> implements Cloneable {
024  private static final long serialVersionUID = 0L;
025
026  /**
027   * <code>repeated double x_initial = 1;</code>
028   */
029  private final RepeatedDouble xInitial = RepeatedDouble.newEmptyInstance();
030
031  /**
032   * <code>repeated double x_final = 2;</code>
033   */
034  private final RepeatedDouble xFinal = RepeatedDouble.newEmptyInstance();
035
036  /**
037   * <code>repeated double y_initial = 3;</code>
038   */
039  private final RepeatedDouble yInitial = RepeatedDouble.newEmptyInstance();
040
041  /**
042   * <code>repeated double y_final = 4;</code>
043   */
044  private final RepeatedDouble yFinal = RepeatedDouble.newEmptyInstance();
045
046  private ProtobufCubicHermiteSpline() {
047  }
048
049  /**
050   * @return a new empty instance of {@code ProtobufCubicHermiteSpline}
051   */
052  public static ProtobufCubicHermiteSpline newInstance() {
053    return new ProtobufCubicHermiteSpline();
054  }
055
056  /**
057   * <code>repeated double x_initial = 1;</code>
058   * @return whether the xInitial field is set
059   */
060  public boolean hasXInitial() {
061    return (bitField0_ & 0x00000001) != 0;
062  }
063
064  /**
065   * <code>repeated double x_initial = 1;</code>
066   * @return this
067   */
068  public ProtobufCubicHermiteSpline clearXInitial() {
069    bitField0_ &= ~0x00000001;
070    xInitial.clear();
071    return this;
072  }
073
074  /**
075   * <code>repeated double x_initial = 1;</code>
076   *
077   * This method returns the internal storage object without modifying any has state.
078   * The returned object should not be modified and be treated as read-only.
079   *
080   * Use {@link #getMutableXInitial()} if you want to modify it.
081   *
082   * @return internal storage object for reading
083   */
084  public RepeatedDouble getXInitial() {
085    return xInitial;
086  }
087
088  /**
089   * <code>repeated double x_initial = 1;</code>
090   *
091   * This method returns the internal storage object and sets the corresponding
092   * has state. The returned object will become part of this message and its
093   * contents may be modified as long as the has state is not cleared.
094   *
095   * @return internal storage object for modifications
096   */
097  public RepeatedDouble getMutableXInitial() {
098    bitField0_ |= 0x00000001;
099    return xInitial;
100  }
101
102  /**
103   * <code>repeated double x_initial = 1;</code>
104   * @param value the xInitial to add
105   * @return this
106   */
107  public ProtobufCubicHermiteSpline addXInitial(final double value) {
108    bitField0_ |= 0x00000001;
109    xInitial.add(value);
110    return this;
111  }
112
113  /**
114   * <code>repeated double x_initial = 1;</code>
115   * @param values the xInitial to add
116   * @return this
117   */
118  public ProtobufCubicHermiteSpline addAllXInitial(final double... values) {
119    bitField0_ |= 0x00000001;
120    xInitial.addAll(values);
121    return this;
122  }
123
124  /**
125   * <code>repeated double x_final = 2;</code>
126   * @return whether the xFinal field is set
127   */
128  public boolean hasXFinal() {
129    return (bitField0_ & 0x00000002) != 0;
130  }
131
132  /**
133   * <code>repeated double x_final = 2;</code>
134   * @return this
135   */
136  public ProtobufCubicHermiteSpline clearXFinal() {
137    bitField0_ &= ~0x00000002;
138    xFinal.clear();
139    return this;
140  }
141
142  /**
143   * <code>repeated double x_final = 2;</code>
144   *
145   * This method returns the internal storage object without modifying any has state.
146   * The returned object should not be modified and be treated as read-only.
147   *
148   * Use {@link #getMutableXFinal()} if you want to modify it.
149   *
150   * @return internal storage object for reading
151   */
152  public RepeatedDouble getXFinal() {
153    return xFinal;
154  }
155
156  /**
157   * <code>repeated double x_final = 2;</code>
158   *
159   * This method returns the internal storage object and sets the corresponding
160   * has state. The returned object will become part of this message and its
161   * contents may be modified as long as the has state is not cleared.
162   *
163   * @return internal storage object for modifications
164   */
165  public RepeatedDouble getMutableXFinal() {
166    bitField0_ |= 0x00000002;
167    return xFinal;
168  }
169
170  /**
171   * <code>repeated double x_final = 2;</code>
172   * @param value the xFinal to add
173   * @return this
174   */
175  public ProtobufCubicHermiteSpline addXFinal(final double value) {
176    bitField0_ |= 0x00000002;
177    xFinal.add(value);
178    return this;
179  }
180
181  /**
182   * <code>repeated double x_final = 2;</code>
183   * @param values the xFinal to add
184   * @return this
185   */
186  public ProtobufCubicHermiteSpline addAllXFinal(final double... values) {
187    bitField0_ |= 0x00000002;
188    xFinal.addAll(values);
189    return this;
190  }
191
192  /**
193   * <code>repeated double y_initial = 3;</code>
194   * @return whether the yInitial field is set
195   */
196  public boolean hasYInitial() {
197    return (bitField0_ & 0x00000004) != 0;
198  }
199
200  /**
201   * <code>repeated double y_initial = 3;</code>
202   * @return this
203   */
204  public ProtobufCubicHermiteSpline clearYInitial() {
205    bitField0_ &= ~0x00000004;
206    yInitial.clear();
207    return this;
208  }
209
210  /**
211   * <code>repeated double y_initial = 3;</code>
212   *
213   * This method returns the internal storage object without modifying any has state.
214   * The returned object should not be modified and be treated as read-only.
215   *
216   * Use {@link #getMutableYInitial()} if you want to modify it.
217   *
218   * @return internal storage object for reading
219   */
220  public RepeatedDouble getYInitial() {
221    return yInitial;
222  }
223
224  /**
225   * <code>repeated double y_initial = 3;</code>
226   *
227   * This method returns the internal storage object and sets the corresponding
228   * has state. The returned object will become part of this message and its
229   * contents may be modified as long as the has state is not cleared.
230   *
231   * @return internal storage object for modifications
232   */
233  public RepeatedDouble getMutableYInitial() {
234    bitField0_ |= 0x00000004;
235    return yInitial;
236  }
237
238  /**
239   * <code>repeated double y_initial = 3;</code>
240   * @param value the yInitial to add
241   * @return this
242   */
243  public ProtobufCubicHermiteSpline addYInitial(final double value) {
244    bitField0_ |= 0x00000004;
245    yInitial.add(value);
246    return this;
247  }
248
249  /**
250   * <code>repeated double y_initial = 3;</code>
251   * @param values the yInitial to add
252   * @return this
253   */
254  public ProtobufCubicHermiteSpline addAllYInitial(final double... values) {
255    bitField0_ |= 0x00000004;
256    yInitial.addAll(values);
257    return this;
258  }
259
260  /**
261   * <code>repeated double y_final = 4;</code>
262   * @return whether the yFinal field is set
263   */
264  public boolean hasYFinal() {
265    return (bitField0_ & 0x00000008) != 0;
266  }
267
268  /**
269   * <code>repeated double y_final = 4;</code>
270   * @return this
271   */
272  public ProtobufCubicHermiteSpline clearYFinal() {
273    bitField0_ &= ~0x00000008;
274    yFinal.clear();
275    return this;
276  }
277
278  /**
279   * <code>repeated double y_final = 4;</code>
280   *
281   * This method returns the internal storage object without modifying any has state.
282   * The returned object should not be modified and be treated as read-only.
283   *
284   * Use {@link #getMutableYFinal()} if you want to modify it.
285   *
286   * @return internal storage object for reading
287   */
288  public RepeatedDouble getYFinal() {
289    return yFinal;
290  }
291
292  /**
293   * <code>repeated double y_final = 4;</code>
294   *
295   * This method returns the internal storage object and sets the corresponding
296   * has state. The returned object will become part of this message and its
297   * contents may be modified as long as the has state is not cleared.
298   *
299   * @return internal storage object for modifications
300   */
301  public RepeatedDouble getMutableYFinal() {
302    bitField0_ |= 0x00000008;
303    return yFinal;
304  }
305
306  /**
307   * <code>repeated double y_final = 4;</code>
308   * @param value the yFinal to add
309   * @return this
310   */
311  public ProtobufCubicHermiteSpline addYFinal(final double value) {
312    bitField0_ |= 0x00000008;
313    yFinal.add(value);
314    return this;
315  }
316
317  /**
318   * <code>repeated double y_final = 4;</code>
319   * @param values the yFinal to add
320   * @return this
321   */
322  public ProtobufCubicHermiteSpline addAllYFinal(final double... values) {
323    bitField0_ |= 0x00000008;
324    yFinal.addAll(values);
325    return this;
326  }
327
328  @Override
329  public ProtobufCubicHermiteSpline copyFrom(final ProtobufCubicHermiteSpline other) {
330    cachedSize = other.cachedSize;
331    if ((bitField0_ | other.bitField0_) != 0) {
332      bitField0_ = other.bitField0_;
333      xInitial.copyFrom(other.xInitial);
334      xFinal.copyFrom(other.xFinal);
335      yInitial.copyFrom(other.yInitial);
336      yFinal.copyFrom(other.yFinal);
337    }
338    return this;
339  }
340
341  @Override
342  public ProtobufCubicHermiteSpline mergeFrom(final ProtobufCubicHermiteSpline other) {
343    if (other.isEmpty()) {
344      return this;
345    }
346    cachedSize = -1;
347    if (other.hasXInitial()) {
348      getMutableXInitial().addAll(other.xInitial);
349    }
350    if (other.hasXFinal()) {
351      getMutableXFinal().addAll(other.xFinal);
352    }
353    if (other.hasYInitial()) {
354      getMutableYInitial().addAll(other.yInitial);
355    }
356    if (other.hasYFinal()) {
357      getMutableYFinal().addAll(other.yFinal);
358    }
359    return this;
360  }
361
362  @Override
363  public ProtobufCubicHermiteSpline clear() {
364    if (isEmpty()) {
365      return this;
366    }
367    cachedSize = -1;
368    bitField0_ = 0;
369    xInitial.clear();
370    xFinal.clear();
371    yInitial.clear();
372    yFinal.clear();
373    return this;
374  }
375
376  @Override
377  public ProtobufCubicHermiteSpline clearQuick() {
378    if (isEmpty()) {
379      return this;
380    }
381    cachedSize = -1;
382    bitField0_ = 0;
383    xInitial.clear();
384    xFinal.clear();
385    yInitial.clear();
386    yFinal.clear();
387    return this;
388  }
389
390  @Override
391  public boolean equals(Object o) {
392    if (o == this) {
393      return true;
394    }
395    if (!(o instanceof ProtobufCubicHermiteSpline)) {
396      return false;
397    }
398    ProtobufCubicHermiteSpline other = (ProtobufCubicHermiteSpline) o;
399    return bitField0_ == other.bitField0_
400      && (!hasXInitial() || xInitial.equals(other.xInitial))
401      && (!hasXFinal() || xFinal.equals(other.xFinal))
402      && (!hasYInitial() || yInitial.equals(other.yInitial))
403      && (!hasYFinal() || yFinal.equals(other.yFinal));
404  }
405
406  @Override
407  public void writeTo(final ProtoSink output) throws IOException {
408    if ((bitField0_ & 0x00000001) != 0) {
409      for (int i = 0; i < xInitial.length(); i++) {
410        output.writeRawByte((byte) 9);
411        output.writeDoubleNoTag(xInitial.array()[i]);
412      }
413    }
414    if ((bitField0_ & 0x00000002) != 0) {
415      for (int i = 0; i < xFinal.length(); i++) {
416        output.writeRawByte((byte) 17);
417        output.writeDoubleNoTag(xFinal.array()[i]);
418      }
419    }
420    if ((bitField0_ & 0x00000004) != 0) {
421      for (int i = 0; i < yInitial.length(); i++) {
422        output.writeRawByte((byte) 25);
423        output.writeDoubleNoTag(yInitial.array()[i]);
424      }
425    }
426    if ((bitField0_ & 0x00000008) != 0) {
427      for (int i = 0; i < yFinal.length(); i++) {
428        output.writeRawByte((byte) 33);
429        output.writeDoubleNoTag(yFinal.array()[i]);
430      }
431    }
432  }
433
434  @Override
435  protected int computeSerializedSize() {
436    int size = 0;
437    if ((bitField0_ & 0x00000001) != 0) {
438      size += (1 + 8) * xInitial.length();
439    }
440    if ((bitField0_ & 0x00000002) != 0) {
441      size += (1 + 8) * xFinal.length();
442    }
443    if ((bitField0_ & 0x00000004) != 0) {
444      size += (1 + 8) * yInitial.length();
445    }
446    if ((bitField0_ & 0x00000008) != 0) {
447      size += (1 + 8) * yFinal.length();
448    }
449    return size;
450  }
451
452  @Override
453  @SuppressWarnings("fallthrough")
454  public ProtobufCubicHermiteSpline mergeFrom(final ProtoSource input) throws IOException {
455    // Enabled Fall-Through Optimization (QuickBuffers)
456    int tag = input.readTag();
457    while (true) {
458      switch (tag) {
459        case 10: {
460          // xInitial [packed=true]
461          input.readPackedDouble(xInitial);
462          bitField0_ |= 0x00000001;
463          tag = input.readTag();
464          if (tag != 18) {
465            break;
466          }
467        }
468        case 18: {
469          // xFinal [packed=true]
470          input.readPackedDouble(xFinal);
471          bitField0_ |= 0x00000002;
472          tag = input.readTag();
473          if (tag != 26) {
474            break;
475          }
476        }
477        case 26: {
478          // yInitial [packed=true]
479          input.readPackedDouble(yInitial);
480          bitField0_ |= 0x00000004;
481          tag = input.readTag();
482          if (tag != 34) {
483            break;
484          }
485        }
486        case 34: {
487          // yFinal [packed=true]
488          input.readPackedDouble(yFinal);
489          bitField0_ |= 0x00000008;
490          tag = input.readTag();
491          if (tag != 0) {
492            break;
493          }
494        }
495        case 0: {
496          return this;
497        }
498        default: {
499          if (!input.skipField(tag)) {
500            return this;
501          }
502          tag = input.readTag();
503          break;
504        }
505        case 9: {
506          // xInitial [packed=false]
507          tag = input.readRepeatedDouble(xInitial, tag);
508          bitField0_ |= 0x00000001;
509          break;
510        }
511        case 17: {
512          // xFinal [packed=false]
513          tag = input.readRepeatedDouble(xFinal, tag);
514          bitField0_ |= 0x00000002;
515          break;
516        }
517        case 25: {
518          // yInitial [packed=false]
519          tag = input.readRepeatedDouble(yInitial, tag);
520          bitField0_ |= 0x00000004;
521          break;
522        }
523        case 33: {
524          // yFinal [packed=false]
525          tag = input.readRepeatedDouble(yFinal, tag);
526          bitField0_ |= 0x00000008;
527          break;
528        }
529      }
530    }
531  }
532
533  @Override
534  public void writeTo(final JsonSink output) throws IOException {
535    output.beginObject();
536    if ((bitField0_ & 0x00000001) != 0) {
537      output.writeRepeatedDouble(FieldNames.xInitial, xInitial);
538    }
539    if ((bitField0_ & 0x00000002) != 0) {
540      output.writeRepeatedDouble(FieldNames.xFinal, xFinal);
541    }
542    if ((bitField0_ & 0x00000004) != 0) {
543      output.writeRepeatedDouble(FieldNames.yInitial, yInitial);
544    }
545    if ((bitField0_ & 0x00000008) != 0) {
546      output.writeRepeatedDouble(FieldNames.yFinal, yFinal);
547    }
548    output.endObject();
549  }
550
551  @Override
552  public ProtobufCubicHermiteSpline mergeFrom(final JsonSource input) throws IOException {
553    if (!input.beginObject()) {
554      return this;
555    }
556    while (!input.isAtEnd()) {
557      switch (input.readFieldHash()) {
558        case -1998129236:
559        case -2134571395: {
560          if (input.isAtField(FieldNames.xInitial)) {
561            if (!input.trySkipNullValue()) {
562              input.readRepeatedDouble(xInitial);
563              bitField0_ |= 0x00000001;
564            }
565          } else {
566            input.skipUnknownField();
567          }
568          break;
569        }
570        case -791585826:
571        case 1943464687: {
572          if (input.isAtField(FieldNames.xFinal)) {
573            if (!input.trySkipNullValue()) {
574              input.readRepeatedDouble(xFinal);
575              bitField0_ |= 0x00000002;
576            }
577          } else {
578            input.skipUnknownField();
579          }
580          break;
581        }
582        case -255318901:
583        case 352941438: {
584          if (input.isAtField(FieldNames.yInitial)) {
585            if (!input.trySkipNullValue()) {
586              input.readRepeatedDouble(yInitial);
587              bitField0_ |= 0x00000004;
588            }
589          } else {
590            input.skipUnknownField();
591          }
592          break;
593        }
594        case -762956675:
595        case -1463998928: {
596          if (input.isAtField(FieldNames.yFinal)) {
597            if (!input.trySkipNullValue()) {
598              input.readRepeatedDouble(yFinal);
599              bitField0_ |= 0x00000008;
600            }
601          } else {
602            input.skipUnknownField();
603          }
604          break;
605        }
606        default: {
607          input.skipUnknownField();
608          break;
609        }
610      }
611    }
612    input.endObject();
613    return this;
614  }
615
616  @Override
617  public ProtobufCubicHermiteSpline clone() {
618    return new ProtobufCubicHermiteSpline().copyFrom(this);
619  }
620
621  @Override
622  public boolean isEmpty() {
623    return ((bitField0_) == 0);
624  }
625
626  public static ProtobufCubicHermiteSpline parseFrom(final byte[] data) throws
627      InvalidProtocolBufferException {
628    return ProtoMessage.mergeFrom(new ProtobufCubicHermiteSpline(), data).checkInitialized();
629  }
630
631  public static ProtobufCubicHermiteSpline parseFrom(final ProtoSource input) throws IOException {
632    return ProtoMessage.mergeFrom(new ProtobufCubicHermiteSpline(), input).checkInitialized();
633  }
634
635  public static ProtobufCubicHermiteSpline parseFrom(final JsonSource input) throws IOException {
636    return ProtoMessage.mergeFrom(new ProtobufCubicHermiteSpline(), input).checkInitialized();
637  }
638
639  /**
640   * @return factory for creating ProtobufCubicHermiteSpline messages
641   */
642  public static MessageFactory<ProtobufCubicHermiteSpline> getFactory() {
643    return ProtobufCubicHermiteSplineFactory.INSTANCE;
644  }
645
646  /**
647   * @return this type's descriptor.
648   */
649  public static Descriptors.Descriptor getDescriptor() {
650    return ProtobufSplineDescriptor.wpi_proto_ProtobufCubicHermiteSpline_descriptor;
651  }
652
653  private enum ProtobufCubicHermiteSplineFactory implements MessageFactory<ProtobufCubicHermiteSpline> {
654    INSTANCE;
655
656    @Override
657    public ProtobufCubicHermiteSpline create() {
658      return ProtobufCubicHermiteSpline.newInstance();
659    }
660  }
661
662  /**
663   * Contains name constants used for serializing JSON
664   */
665  static class FieldNames {
666    static final FieldName xInitial = FieldName.forField("xInitial", "x_initial");
667
668    static final FieldName xFinal = FieldName.forField("xFinal", "x_final");
669
670    static final FieldName yInitial = FieldName.forField("yInitial", "y_initial");
671
672    static final FieldName yFinal = FieldName.forField("yFinal", "y_final");
673  }
674}