// 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 edu.wpi.first.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;
import us.hebi.quickbuf.RepeatedByte;

public final class Plant {
  private static final RepeatedByte descriptorData = ProtoUtil.decodeBase64(610,
    "CgtwbGFudC5wcm90bxIJd3BpLnByb3RvIsQBCg9Qcm90b2J1ZkRDTW90b3ISJwoPbm9taW5hbF92b2x0" + 
    "YWdlGAEgASgBUg5ub21pbmFsVm9sdGFnZRIhCgxzdGFsbF90b3JxdWUYAiABKAFSC3N0YWxsVG9ycXVl" + 
    "EiMKDXN0YWxsX2N1cnJlbnQYAyABKAFSDHN0YWxsQ3VycmVudBIhCgxmcmVlX2N1cnJlbnQYBCABKAFS" + 
    "C2ZyZWVDdXJyZW50Eh0KCmZyZWVfc3BlZWQYBSABKAFSCWZyZWVTcGVlZEIaChhlZHUud3BpLmZpcnN0" + 
    "Lm1hdGgucHJvdG9K3AIKBhIEAAAMAQoICgEMEgMAABIKCAoBAhIDAgASCggKAQgSAwQAMQoJCgIIARID" + 
    "BAAxCgoKAgQAEgQGAAwBCgoKAwQAARIDBggXCgsKBAQAAgASAwcCHQoMCgUEAAIABRIDBwIICgwKBQQA" + 
    "AgABEgMHCRgKDAoFBAACAAMSAwcbHAoLCgQEAAIBEgMIAhoKDAoFBAACAQUSAwgCCAoMCgUEAAIBARID" + 
    "CAkVCgwKBQQAAgEDEgMIGBkKCwoEBAACAhIDCQIbCgwKBQQAAgIFEgMJAggKDAoFBAACAgESAwkJFgoM" + 
    "CgUEAAICAxIDCRkaCgsKBAQAAgMSAwoCGgoMCgUEAAIDBRIDCgIICgwKBQQAAgMBEgMKCRUKDAoFBAAC" + 
    "AwMSAwoYGQoLCgQEAAIEEgMLAhgKDAoFBAACBAUSAwsCCAoMCgUEAAIEARIDCwkTCgwKBQQAAgQDEgML" + 
    "FhdiBnByb3RvMw==");

  static final Descriptors.FileDescriptor descriptor = Descriptors.FileDescriptor.internalBuildGeneratedFileFrom("plant.proto", "wpi.proto", descriptorData);

  static final Descriptors.Descriptor wpi_proto_ProtobufDCMotor_descriptor = descriptor.internalContainedType(27, 196, "ProtobufDCMotor", "wpi.proto.ProtobufDCMotor");

  /**
   * @return this proto file's descriptor.
   */
  public static Descriptors.FileDescriptor getDescriptor() {
    return descriptor;
  }

  /**
   * Protobuf type {@code ProtobufDCMotor}
   */
  public static final class ProtobufDCMotor extends ProtoMessage<ProtobufDCMotor> implements Cloneable {
    private static final long serialVersionUID = 0L;

    /**
     * <code>optional double nominal_voltage = 1;</code>
     */
    private double nominalVoltage;

    /**
     * <code>optional double stall_torque = 2;</code>
     */
    private double stallTorque;

    /**
     * <code>optional double stall_current = 3;</code>
     */
    private double stallCurrent;

    /**
     * <code>optional double free_current = 4;</code>
     */
    private double freeCurrent;

    /**
     * <code>optional double free_speed = 5;</code>
     */
    private double freeSpeed;

    private ProtobufDCMotor() {
    }

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

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

    /**
     * <code>optional double nominal_voltage = 1;</code>
     * @return this
     */
    public ProtobufDCMotor clearNominalVoltage() {
      bitField0_ &= ~0x00000001;
      nominalVoltage = 0D;
      return this;
    }

    /**
     * <code>optional double nominal_voltage = 1;</code>
     * @return the nominalVoltage
     */
    public double getNominalVoltage() {
      return nominalVoltage;
    }

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

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

    /**
     * <code>optional double stall_torque = 2;</code>
     * @return this
     */
    public ProtobufDCMotor clearStallTorque() {
      bitField0_ &= ~0x00000002;
      stallTorque = 0D;
      return this;
    }

    /**
     * <code>optional double stall_torque = 2;</code>
     * @return the stallTorque
     */
    public double getStallTorque() {
      return stallTorque;
    }

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

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

    /**
     * <code>optional double stall_current = 3;</code>
     * @return this
     */
    public ProtobufDCMotor clearStallCurrent() {
      bitField0_ &= ~0x00000004;
      stallCurrent = 0D;
      return this;
    }

    /**
     * <code>optional double stall_current = 3;</code>
     * @return the stallCurrent
     */
    public double getStallCurrent() {
      return stallCurrent;
    }

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

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

    /**
     * <code>optional double free_current = 4;</code>
     * @return this
     */
    public ProtobufDCMotor clearFreeCurrent() {
      bitField0_ &= ~0x00000008;
      freeCurrent = 0D;
      return this;
    }

    /**
     * <code>optional double free_current = 4;</code>
     * @return the freeCurrent
     */
    public double getFreeCurrent() {
      return freeCurrent;
    }

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

    /**
     * <code>optional double free_speed = 5;</code>
     * @return whether the freeSpeed field is set
     */
    public boolean hasFreeSpeed() {
      return (bitField0_ & 0x00000010) != 0;
    }

    /**
     * <code>optional double free_speed = 5;</code>
     * @return this
     */
    public ProtobufDCMotor clearFreeSpeed() {
      bitField0_ &= ~0x00000010;
      freeSpeed = 0D;
      return this;
    }

    /**
     * <code>optional double free_speed = 5;</code>
     * @return the freeSpeed
     */
    public double getFreeSpeed() {
      return freeSpeed;
    }

    /**
     * <code>optional double free_speed = 5;</code>
     * @param value the freeSpeed to set
     * @return this
     */
    public ProtobufDCMotor setFreeSpeed(final double value) {
      bitField0_ |= 0x00000010;
      freeSpeed = value;
      return this;
    }

    @Override
    public ProtobufDCMotor copyFrom(final ProtobufDCMotor other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        nominalVoltage = other.nominalVoltage;
        stallTorque = other.stallTorque;
        stallCurrent = other.stallCurrent;
        freeCurrent = other.freeCurrent;
        freeSpeed = other.freeSpeed;
      }
      return this;
    }

    @Override
    public ProtobufDCMotor mergeFrom(final ProtobufDCMotor other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasNominalVoltage()) {
        setNominalVoltage(other.nominalVoltage);
      }
      if (other.hasStallTorque()) {
        setStallTorque(other.stallTorque);
      }
      if (other.hasStallCurrent()) {
        setStallCurrent(other.stallCurrent);
      }
      if (other.hasFreeCurrent()) {
        setFreeCurrent(other.freeCurrent);
      }
      if (other.hasFreeSpeed()) {
        setFreeSpeed(other.freeSpeed);
      }
      return this;
    }

    @Override
    public ProtobufDCMotor clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      nominalVoltage = 0D;
      stallTorque = 0D;
      stallCurrent = 0D;
      freeCurrent = 0D;
      freeSpeed = 0D;
      return this;
    }

    @Override
    public ProtobufDCMotor 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 ProtobufDCMotor)) {
        return false;
      }
      ProtobufDCMotor other = (ProtobufDCMotor) o;
      return bitField0_ == other.bitField0_
        && (!hasNominalVoltage() || ProtoUtil.isEqual(nominalVoltage, other.nominalVoltage))
        && (!hasStallTorque() || ProtoUtil.isEqual(stallTorque, other.stallTorque))
        && (!hasStallCurrent() || ProtoUtil.isEqual(stallCurrent, other.stallCurrent))
        && (!hasFreeCurrent() || ProtoUtil.isEqual(freeCurrent, other.freeCurrent))
        && (!hasFreeSpeed() || ProtoUtil.isEqual(freeSpeed, other.freeSpeed));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 9);
        output.writeDoubleNoTag(nominalVoltage);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 17);
        output.writeDoubleNoTag(stallTorque);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 25);
        output.writeDoubleNoTag(stallCurrent);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 33);
        output.writeDoubleNoTag(freeCurrent);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRawByte((byte) 41);
        output.writeDoubleNoTag(freeSpeed);
      }
    }

    @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;
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += 9;
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ProtobufDCMotor mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 9: {
            // nominalVoltage
            nominalVoltage = input.readDouble();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 17) {
              break;
            }
          }
          case 17: {
            // stallTorque
            stallTorque = input.readDouble();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 25) {
              break;
            }
          }
          case 25: {
            // stallCurrent
            stallCurrent = input.readDouble();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 33) {
              break;
            }
          }
          case 33: {
            // freeCurrent
            freeCurrent = input.readDouble();
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 41) {
              break;
            }
          }
          case 41: {
            // freeSpeed
            freeSpeed = input.readDouble();
            bitField0_ |= 0x00000010;
            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.nominalVoltage, nominalVoltage);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeDouble(FieldNames.stallTorque, stallTorque);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeDouble(FieldNames.stallCurrent, stallCurrent);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeDouble(FieldNames.freeCurrent, freeCurrent);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeDouble(FieldNames.freeSpeed, freeSpeed);
      }
      output.endObject();
    }

    @Override
    public ProtobufDCMotor mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1374862050:
          case 173092603: {
            if (input.isAtField(FieldNames.nominalVoltage)) {
              if (!input.trySkipNullValue()) {
                nominalVoltage = input.readDouble();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2075810250:
          case 1238615945: {
            if (input.isAtField(FieldNames.stallTorque)) {
              if (!input.trySkipNullValue()) {
                stallTorque = input.readDouble();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2105262663:
          case 2006484954: {
            if (input.isAtField(FieldNames.stallCurrent)) {
              if (!input.trySkipNullValue()) {
                stallCurrent = input.readDouble();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1024355693:
          case 240406182: {
            if (input.isAtField(FieldNames.freeCurrent)) {
              if (!input.trySkipNullValue()) {
                freeCurrent = input.readDouble();
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -444654277:
          case -552732492: {
            if (input.isAtField(FieldNames.freeSpeed)) {
              if (!input.trySkipNullValue()) {
                freeSpeed = input.readDouble();
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

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

    private enum ProtobufDCMotorFactory implements MessageFactory<ProtobufDCMotor> {
      INSTANCE;

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

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

      static final FieldName stallTorque = FieldName.forField("stallTorque", "stall_torque");

      static final FieldName stallCurrent = FieldName.forField("stallCurrent", "stall_current");

      static final FieldName freeCurrent = FieldName.forField("freeCurrent", "free_current");

      static final FieldName freeSpeed = FieldName.forField("freeSpeed", "free_speed");
    }
  }
}
