// 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 ProtobufSimpleMotorFeedforward}
 */
@SuppressWarnings("hiding")
public final class ProtobufSimpleMotorFeedforward extends ProtoMessage<ProtobufSimpleMotorFeedforward> implements Cloneable {
  private static final long serialVersionUID = 0L;

  /**
   * <code>optional double ks = 1;</code>
   */
  private double ks;

  /**
   * <code>optional double kv = 2;</code>
   */
  private double kv;

  /**
   * <code>optional double ka = 3;</code>
   */
  private double ka;

  /**
   * <code>optional double dt = 4;</code>
   */
  private double dt;

  private ProtobufSimpleMotorFeedforward() {
  }

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

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

  /**
   * <code>optional double ks = 1;</code>
   * @return this
   */
  public ProtobufSimpleMotorFeedforward clearKs() {
    bitField0_ &= ~0x00000001;
    ks = 0D;
    return this;
  }

  /**
   * <code>optional double ks = 1;</code>
   * @return the ks
   */
  public double getKs() {
    return ks;
  }

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

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

  /**
   * <code>optional double kv = 2;</code>
   * @return this
   */
  public ProtobufSimpleMotorFeedforward clearKv() {
    bitField0_ &= ~0x00000002;
    kv = 0D;
    return this;
  }

  /**
   * <code>optional double kv = 2;</code>
   * @return the kv
   */
  public double getKv() {
    return kv;
  }

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

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

  /**
   * <code>optional double ka = 3;</code>
   * @return this
   */
  public ProtobufSimpleMotorFeedforward clearKa() {
    bitField0_ &= ~0x00000004;
    ka = 0D;
    return this;
  }

  /**
   * <code>optional double ka = 3;</code>
   * @return the ka
   */
  public double getKa() {
    return ka;
  }

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

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

  /**
   * <code>optional double dt = 4;</code>
   * @return this
   */
  public ProtobufSimpleMotorFeedforward clearDt() {
    bitField0_ &= ~0x00000008;
    dt = 0D;
    return this;
  }

  /**
   * <code>optional double dt = 4;</code>
   * @return the dt
   */
  public double getDt() {
    return dt;
  }

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

  @Override
  public ProtobufSimpleMotorFeedforward copyFrom(final ProtobufSimpleMotorFeedforward other) {
    cachedSize = other.cachedSize;
    if ((bitField0_ | other.bitField0_) != 0) {
      bitField0_ = other.bitField0_;
      ks = other.ks;
      kv = other.kv;
      ka = other.ka;
      dt = other.dt;
    }
    return this;
  }

  @Override
  public ProtobufSimpleMotorFeedforward mergeFrom(final ProtobufSimpleMotorFeedforward other) {
    if (other.isEmpty()) {
      return this;
    }
    cachedSize = -1;
    if (other.hasKs()) {
      setKs(other.ks);
    }
    if (other.hasKv()) {
      setKv(other.kv);
    }
    if (other.hasKa()) {
      setKa(other.ka);
    }
    if (other.hasDt()) {
      setDt(other.dt);
    }
    return this;
  }

  @Override
  public ProtobufSimpleMotorFeedforward clear() {
    if (isEmpty()) {
      return this;
    }
    cachedSize = -1;
    bitField0_ = 0;
    ks = 0D;
    kv = 0D;
    ka = 0D;
    dt = 0D;
    return this;
  }

  @Override
  public ProtobufSimpleMotorFeedforward 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 ProtobufSimpleMotorFeedforward)) {
      return false;
    }
    ProtobufSimpleMotorFeedforward other = (ProtobufSimpleMotorFeedforward) o;
    return bitField0_ == other.bitField0_
      && (!hasKs() || ProtoUtil.isEqual(ks, other.ks))
      && (!hasKv() || ProtoUtil.isEqual(kv, other.kv))
      && (!hasKa() || ProtoUtil.isEqual(ka, other.ka))
      && (!hasDt() || ProtoUtil.isEqual(dt, other.dt));
  }

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

  @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 ProtobufSimpleMotorFeedforward mergeFrom(final ProtoSource input) throws IOException {
    // Enabled Fall-Through Optimization (QuickBuffers)
    int tag = input.readTag();
    while (true) {
      switch (tag) {
        case 9: {
          // ks
          ks = input.readDouble();
          bitField0_ |= 0x00000001;
          tag = input.readTag();
          if (tag != 17) {
            break;
          }
        }
        case 17: {
          // kv
          kv = input.readDouble();
          bitField0_ |= 0x00000002;
          tag = input.readTag();
          if (tag != 25) {
            break;
          }
        }
        case 25: {
          // ka
          ka = input.readDouble();
          bitField0_ |= 0x00000004;
          tag = input.readTag();
          if (tag != 33) {
            break;
          }
        }
        case 33: {
          // dt
          dt = 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.ks, ks);
    }
    if ((bitField0_ & 0x00000002) != 0) {
      output.writeDouble(FieldNames.kv, kv);
    }
    if ((bitField0_ & 0x00000004) != 0) {
      output.writeDouble(FieldNames.ka, ka);
    }
    if ((bitField0_ & 0x00000008) != 0) {
      output.writeDouble(FieldNames.dt, dt);
    }
    output.endObject();
  }

  @Override
  public ProtobufSimpleMotorFeedforward mergeFrom(final JsonSource input) throws IOException {
    if (!input.beginObject()) {
      return this;
    }
    while (!input.isAtEnd()) {
      switch (input.readFieldHash()) {
        case 3432: {
          if (input.isAtField(FieldNames.ks)) {
            if (!input.trySkipNullValue()) {
              ks = input.readDouble();
              bitField0_ |= 0x00000001;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case 3435: {
          if (input.isAtField(FieldNames.kv)) {
            if (!input.trySkipNullValue()) {
              kv = input.readDouble();
              bitField0_ |= 0x00000002;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case 3414: {
          if (input.isAtField(FieldNames.ka)) {
            if (!input.trySkipNullValue()) {
              ka = input.readDouble();
              bitField0_ |= 0x00000004;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case 3216: {
          if (input.isAtField(FieldNames.dt)) {
            if (!input.trySkipNullValue()) {
              dt = input.readDouble();
              bitField0_ |= 0x00000008;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        default: {
          input.skipUnknownField();
          break;
        }
      }
    }
    input.endObject();
    return this;
  }

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

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

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

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

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

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

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

  private enum ProtobufSimpleMotorFeedforwardFactory implements MessageFactory<ProtobufSimpleMotorFeedforward> {
    INSTANCE;

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

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

    static final FieldName kv = FieldName.forField("kv");

    static final FieldName ka = FieldName.forField("ka");

    static final FieldName dt = FieldName.forField("dt");
  }
}
