// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// Code generated by protocol buffer compiler. Do not edit!
package org.wpilib.math.proto;

import java.io.IOException;
import us.hebi.quickbuf.Descriptors;
import us.hebi.quickbuf.FieldName;
import us.hebi.quickbuf.InvalidProtocolBufferException;
import us.hebi.quickbuf.JsonSink;
import us.hebi.quickbuf.JsonSource;
import us.hebi.quickbuf.MessageFactory;
import us.hebi.quickbuf.ProtoMessage;
import us.hebi.quickbuf.ProtoSink;
import us.hebi.quickbuf.ProtoSource;
import us.hebi.quickbuf.ProtoUtil;

/**
 * Protobuf type {@code ProtobufDifferentialDriveFeedforward}
 */
@SuppressWarnings("hiding")
public final class ProtobufDifferentialDriveFeedforward extends ProtoMessage<ProtobufDifferentialDriveFeedforward> implements Cloneable {
  private static final long serialVersionUID = 0L;

  /**
   * <code>optional double kv_linear = 1;</code>
   */
  private double kvLinear;

  /**
   * <code>optional double ka_linear = 2;</code>
   */
  private double kaLinear;

  /**
   * <code>optional double kv_angular = 3;</code>
   */
  private double kvAngular;

  /**
   * <code>optional double ka_angular = 4;</code>
   */
  private double kaAngular;

  private ProtobufDifferentialDriveFeedforward() {
  }

  /**
   * @return a new empty instance of {@code ProtobufDifferentialDriveFeedforward}
   */
  public static ProtobufDifferentialDriveFeedforward newInstance() {
    return new ProtobufDifferentialDriveFeedforward();
  }

  /**
   * <code>optional double kv_linear = 1;</code>
   * @return whether the kvLinear field is set
   */
  public boolean hasKvLinear() {
    return (bitField0_ & 0x00000001) != 0;
  }

  /**
   * <code>optional double kv_linear = 1;</code>
   * @return this
   */
  public ProtobufDifferentialDriveFeedforward clearKvLinear() {
    bitField0_ &= ~0x00000001;
    kvLinear = 0D;
    return this;
  }

  /**
   * <code>optional double kv_linear = 1;</code>
   * @return the kvLinear
   */
  public double getKvLinear() {
    return kvLinear;
  }

  /**
   * <code>optional double kv_linear = 1;</code>
   * @param value the kvLinear to set
   * @return this
   */
  public ProtobufDifferentialDriveFeedforward setKvLinear(final double value) {
    bitField0_ |= 0x00000001;
    kvLinear = value;
    return this;
  }

  /**
   * <code>optional double ka_linear = 2;</code>
   * @return whether the kaLinear field is set
   */
  public boolean hasKaLinear() {
    return (bitField0_ & 0x00000002) != 0;
  }

  /**
   * <code>optional double ka_linear = 2;</code>
   * @return this
   */
  public ProtobufDifferentialDriveFeedforward clearKaLinear() {
    bitField0_ &= ~0x00000002;
    kaLinear = 0D;
    return this;
  }

  /**
   * <code>optional double ka_linear = 2;</code>
   * @return the kaLinear
   */
  public double getKaLinear() {
    return kaLinear;
  }

  /**
   * <code>optional double ka_linear = 2;</code>
   * @param value the kaLinear to set
   * @return this
   */
  public ProtobufDifferentialDriveFeedforward setKaLinear(final double value) {
    bitField0_ |= 0x00000002;
    kaLinear = value;
    return this;
  }

  /**
   * <code>optional double kv_angular = 3;</code>
   * @return whether the kvAngular field is set
   */
  public boolean hasKvAngular() {
    return (bitField0_ & 0x00000004) != 0;
  }

  /**
   * <code>optional double kv_angular = 3;</code>
   * @return this
   */
  public ProtobufDifferentialDriveFeedforward clearKvAngular() {
    bitField0_ &= ~0x00000004;
    kvAngular = 0D;
    return this;
  }

  /**
   * <code>optional double kv_angular = 3;</code>
   * @return the kvAngular
   */
  public double getKvAngular() {
    return kvAngular;
  }

  /**
   * <code>optional double kv_angular = 3;</code>
   * @param value the kvAngular to set
   * @return this
   */
  public ProtobufDifferentialDriveFeedforward setKvAngular(final double value) {
    bitField0_ |= 0x00000004;
    kvAngular = value;
    return this;
  }

  /**
   * <code>optional double ka_angular = 4;</code>
   * @return whether the kaAngular field is set
   */
  public boolean hasKaAngular() {
    return (bitField0_ & 0x00000008) != 0;
  }

  /**
   * <code>optional double ka_angular = 4;</code>
   * @return this
   */
  public ProtobufDifferentialDriveFeedforward clearKaAngular() {
    bitField0_ &= ~0x00000008;
    kaAngular = 0D;
    return this;
  }

  /**
   * <code>optional double ka_angular = 4;</code>
   * @return the kaAngular
   */
  public double getKaAngular() {
    return kaAngular;
  }

  /**
   * <code>optional double ka_angular = 4;</code>
   * @param value the kaAngular to set
   * @return this
   */
  public ProtobufDifferentialDriveFeedforward setKaAngular(final double value) {
    bitField0_ |= 0x00000008;
    kaAngular = value;
    return this;
  }

  @Override
  public ProtobufDifferentialDriveFeedforward copyFrom(
      final ProtobufDifferentialDriveFeedforward other) {
    cachedSize = other.cachedSize;
    if ((bitField0_ | other.bitField0_) != 0) {
      bitField0_ = other.bitField0_;
      kvLinear = other.kvLinear;
      kaLinear = other.kaLinear;
      kvAngular = other.kvAngular;
      kaAngular = other.kaAngular;
    }
    return this;
  }

  @Override
  public ProtobufDifferentialDriveFeedforward mergeFrom(
      final ProtobufDifferentialDriveFeedforward other) {
    if (other.isEmpty()) {
      return this;
    }
    cachedSize = -1;
    if (other.hasKvLinear()) {
      setKvLinear(other.kvLinear);
    }
    if (other.hasKaLinear()) {
      setKaLinear(other.kaLinear);
    }
    if (other.hasKvAngular()) {
      setKvAngular(other.kvAngular);
    }
    if (other.hasKaAngular()) {
      setKaAngular(other.kaAngular);
    }
    return this;
  }

  @Override
  public ProtobufDifferentialDriveFeedforward clear() {
    if (isEmpty()) {
      return this;
    }
    cachedSize = -1;
    bitField0_ = 0;
    kvLinear = 0D;
    kaLinear = 0D;
    kvAngular = 0D;
    kaAngular = 0D;
    return this;
  }

  @Override
  public ProtobufDifferentialDriveFeedforward clearQuick() {
    if (isEmpty()) {
      return this;
    }
    cachedSize = -1;
    bitField0_ = 0;
    return this;
  }

  @Override
  public boolean equals(Object o) {
    if (o == this) {
      return true;
    }
    if (!(o instanceof ProtobufDifferentialDriveFeedforward)) {
      return false;
    }
    ProtobufDifferentialDriveFeedforward other = (ProtobufDifferentialDriveFeedforward) o;
    return bitField0_ == other.bitField0_
      && (!hasKvLinear() || ProtoUtil.isEqual(kvLinear, other.kvLinear))
      && (!hasKaLinear() || ProtoUtil.isEqual(kaLinear, other.kaLinear))
      && (!hasKvAngular() || ProtoUtil.isEqual(kvAngular, other.kvAngular))
      && (!hasKaAngular() || ProtoUtil.isEqual(kaAngular, other.kaAngular));
  }

  @Override
  public void writeTo(final ProtoSink output) throws IOException {
    if ((bitField0_ & 0x00000001) != 0) {
      output.writeRawByte((byte) 9);
      output.writeDoubleNoTag(kvLinear);
    }
    if ((bitField0_ & 0x00000002) != 0) {
      output.writeRawByte((byte) 17);
      output.writeDoubleNoTag(kaLinear);
    }
    if ((bitField0_ & 0x00000004) != 0) {
      output.writeRawByte((byte) 25);
      output.writeDoubleNoTag(kvAngular);
    }
    if ((bitField0_ & 0x00000008) != 0) {
      output.writeRawByte((byte) 33);
      output.writeDoubleNoTag(kaAngular);
    }
  }

  @Override
  protected int computeSerializedSize() {
    int size = 0;
    if ((bitField0_ & 0x00000001) != 0) {
      size += 9;
    }
    if ((bitField0_ & 0x00000002) != 0) {
      size += 9;
    }
    if ((bitField0_ & 0x00000004) != 0) {
      size += 9;
    }
    if ((bitField0_ & 0x00000008) != 0) {
      size += 9;
    }
    return size;
  }

  @Override
  @SuppressWarnings("fallthrough")
  public ProtobufDifferentialDriveFeedforward mergeFrom(final ProtoSource input) throws
      IOException {
    // Enabled Fall-Through Optimization (QuickBuffers)
    int tag = input.readTag();
    while (true) {
      switch (tag) {
        case 9: {
          // kvLinear
          kvLinear = input.readDouble();
          bitField0_ |= 0x00000001;
          tag = input.readTag();
          if (tag != 17) {
            break;
          }
        }
        case 17: {
          // kaLinear
          kaLinear = input.readDouble();
          bitField0_ |= 0x00000002;
          tag = input.readTag();
          if (tag != 25) {
            break;
          }
        }
        case 25: {
          // kvAngular
          kvAngular = input.readDouble();
          bitField0_ |= 0x00000004;
          tag = input.readTag();
          if (tag != 33) {
            break;
          }
        }
        case 33: {
          // kaAngular
          kaAngular = input.readDouble();
          bitField0_ |= 0x00000008;
          tag = input.readTag();
          if (tag != 0) {
            break;
          }
        }
        case 0: {
          return this;
        }
        default: {
          if (!input.skipField(tag)) {
            return this;
          }
          tag = input.readTag();
          break;
        }
      }
    }
  }

  @Override
  public void writeTo(final JsonSink output) throws IOException {
    output.beginObject();
    if ((bitField0_ & 0x00000001) != 0) {
      output.writeDouble(FieldNames.kvLinear, kvLinear);
    }
    if ((bitField0_ & 0x00000002) != 0) {
      output.writeDouble(FieldNames.kaLinear, kaLinear);
    }
    if ((bitField0_ & 0x00000004) != 0) {
      output.writeDouble(FieldNames.kvAngular, kvAngular);
    }
    if ((bitField0_ & 0x00000008) != 0) {
      output.writeDouble(FieldNames.kaAngular, kaAngular);
    }
    output.endObject();
  }

  @Override
  public ProtobufDifferentialDriveFeedforward mergeFrom(final JsonSource input) throws IOException {
    if (!input.beginObject()) {
      return this;
    }
    while (!input.isAtEnd()) {
      switch (input.readFieldHash()) {
        case 1424526448:
        case 974889081: {
          if (input.isAtField(FieldNames.kvLinear)) {
            if (!input.trySkipNullValue()) {
              kvLinear = input.readDouble();
              bitField0_ |= 0x00000001;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case -33181669:
        case -1264389586: {
          if (input.isAtField(FieldNames.kaLinear)) {
            if (!input.trySkipNullValue()) {
              kaLinear = input.readDouble();
              bitField0_ |= 0x00000002;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case 175208951:
        case -878647538: {
          if (input.isAtField(FieldNames.kvAngular)) {
            if (!input.trySkipNullValue()) {
              kvAngular = input.readDouble();
              bitField0_ |= 0x00000004;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case -2064069716:
        case -1576809479: {
          if (input.isAtField(FieldNames.kaAngular)) {
            if (!input.trySkipNullValue()) {
              kaAngular = input.readDouble();
              bitField0_ |= 0x00000008;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        default: {
          input.skipUnknownField();
          break;
        }
      }
    }
    input.endObject();
    return this;
  }

  @Override
  public ProtobufDifferentialDriveFeedforward clone() {
    return new ProtobufDifferentialDriveFeedforward().copyFrom(this);
  }

  @Override
  public boolean isEmpty() {
    return ((bitField0_) == 0);
  }

  public static ProtobufDifferentialDriveFeedforward parseFrom(final byte[] data) throws
      InvalidProtocolBufferException {
    return ProtoMessage.mergeFrom(new ProtobufDifferentialDriveFeedforward(), data).checkInitialized();
  }

  public static ProtobufDifferentialDriveFeedforward parseFrom(final ProtoSource input) throws
      IOException {
    return ProtoMessage.mergeFrom(new ProtobufDifferentialDriveFeedforward(), input).checkInitialized();
  }

  public static ProtobufDifferentialDriveFeedforward parseFrom(final JsonSource input) throws
      IOException {
    return ProtoMessage.mergeFrom(new ProtobufDifferentialDriveFeedforward(), input).checkInitialized();
  }

  /**
   * @return factory for creating ProtobufDifferentialDriveFeedforward messages
   */
  public static MessageFactory<ProtobufDifferentialDriveFeedforward> getFactory() {
    return ProtobufDifferentialDriveFeedforwardFactory.INSTANCE;
  }

  /**
   * @return this type's descriptor.
   */
  public static Descriptors.Descriptor getDescriptor() {
    return ProtobufControllerDescriptor.wpi_proto_ProtobufDifferentialDriveFeedforward_descriptor;
  }

  private enum ProtobufDifferentialDriveFeedforwardFactory implements MessageFactory<ProtobufDifferentialDriveFeedforward> {
    INSTANCE;

    @Override
    public ProtobufDifferentialDriveFeedforward create() {
      return ProtobufDifferentialDriveFeedforward.newInstance();
    }
  }

  /**
   * Contains name constants used for serializing JSON
   */
  static class FieldNames {
    static final FieldName kvLinear = FieldName.forField("kvLinear", "kv_linear");

    static final FieldName kaLinear = FieldName.forField("kaLinear", "ka_linear");

    static final FieldName kvAngular = FieldName.forField("kvAngular", "kv_angular");

    static final FieldName kaAngular = FieldName.forField("kaAngular", "ka_angular");
  }
}
