// 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;

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

  /**
   * <code>optional uint32 num_states = 1;</code>
   */
  private int numStates;

  /**
   * <code>optional uint32 num_inputs = 2;</code>
   */
  private int numInputs;

  /**
   * <code>optional uint32 num_outputs = 3;</code>
   */
  private int numOutputs;

  /**
   * <code>optional .wpi.proto.ProtobufMatrix a = 4;</code>
   */
  private final ProtobufMatrix a = ProtobufMatrix.newInstance();

  /**
   * <code>optional .wpi.proto.ProtobufMatrix b = 5;</code>
   */
  private final ProtobufMatrix b = ProtobufMatrix.newInstance();

  /**
   * <code>optional .wpi.proto.ProtobufMatrix c = 6;</code>
   */
  private final ProtobufMatrix c = ProtobufMatrix.newInstance();

  /**
   * <code>optional .wpi.proto.ProtobufMatrix d = 7;</code>
   */
  private final ProtobufMatrix d = ProtobufMatrix.newInstance();

  private ProtobufLinearSystem() {
  }

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

  /**
   * <code>optional uint32 num_states = 1;</code>
   * @return whether the numStates field is set
   */
  public boolean hasNumStates() {
    return (bitField0_ & 0x00000001) != 0;
  }

  /**
   * <code>optional uint32 num_states = 1;</code>
   * @return this
   */
  public ProtobufLinearSystem clearNumStates() {
    bitField0_ &= ~0x00000001;
    numStates = 0;
    return this;
  }

  /**
   * <code>optional uint32 num_states = 1;</code>
   * @return the numStates
   */
  public int getNumStates() {
    return numStates;
  }

  /**
   * <code>optional uint32 num_states = 1;</code>
   * @param value the numStates to set
   * @return this
   */
  public ProtobufLinearSystem setNumStates(final int value) {
    bitField0_ |= 0x00000001;
    numStates = value;
    return this;
  }

  /**
   * <code>optional uint32 num_inputs = 2;</code>
   * @return whether the numInputs field is set
   */
  public boolean hasNumInputs() {
    return (bitField0_ & 0x00000002) != 0;
  }

  /**
   * <code>optional uint32 num_inputs = 2;</code>
   * @return this
   */
  public ProtobufLinearSystem clearNumInputs() {
    bitField0_ &= ~0x00000002;
    numInputs = 0;
    return this;
  }

  /**
   * <code>optional uint32 num_inputs = 2;</code>
   * @return the numInputs
   */
  public int getNumInputs() {
    return numInputs;
  }

  /**
   * <code>optional uint32 num_inputs = 2;</code>
   * @param value the numInputs to set
   * @return this
   */
  public ProtobufLinearSystem setNumInputs(final int value) {
    bitField0_ |= 0x00000002;
    numInputs = value;
    return this;
  }

  /**
   * <code>optional uint32 num_outputs = 3;</code>
   * @return whether the numOutputs field is set
   */
  public boolean hasNumOutputs() {
    return (bitField0_ & 0x00000004) != 0;
  }

  /**
   * <code>optional uint32 num_outputs = 3;</code>
   * @return this
   */
  public ProtobufLinearSystem clearNumOutputs() {
    bitField0_ &= ~0x00000004;
    numOutputs = 0;
    return this;
  }

  /**
   * <code>optional uint32 num_outputs = 3;</code>
   * @return the numOutputs
   */
  public int getNumOutputs() {
    return numOutputs;
  }

  /**
   * <code>optional uint32 num_outputs = 3;</code>
   * @param value the numOutputs to set
   * @return this
   */
  public ProtobufLinearSystem setNumOutputs(final int value) {
    bitField0_ |= 0x00000004;
    numOutputs = value;
    return this;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix a = 4;</code>
   * @return whether the a field is set
   */
  public boolean hasA() {
    return (bitField0_ & 0x00000008) != 0;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix a = 4;</code>
   * @return this
   */
  public ProtobufLinearSystem clearA() {
    bitField0_ &= ~0x00000008;
    a.clear();
    return this;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix a = 4;</code>
   *
   * This method returns the internal storage object without modifying any has state.
   * The returned object should not be modified and be treated as read-only.
   *
   * Use {@link #getMutableA()} if you want to modify it.
   *
   * @return internal storage object for reading
   */
  public ProtobufMatrix getA() {
    return a;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix a = 4;</code>
   *
   * This method returns the internal storage object and sets the corresponding
   * has state. The returned object will become part of this message and its
   * contents may be modified as long as the has state is not cleared.
   *
   * @return internal storage object for modifications
   */
  public ProtobufMatrix getMutableA() {
    bitField0_ |= 0x00000008;
    return a;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix a = 4;</code>
   * @param value the a to set
   * @return this
   */
  public ProtobufLinearSystem setA(final ProtobufMatrix value) {
    bitField0_ |= 0x00000008;
    a.copyFrom(value);
    return this;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix b = 5;</code>
   * @return whether the b field is set
   */
  public boolean hasB() {
    return (bitField0_ & 0x00000010) != 0;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix b = 5;</code>
   * @return this
   */
  public ProtobufLinearSystem clearB() {
    bitField0_ &= ~0x00000010;
    b.clear();
    return this;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix b = 5;</code>
   *
   * This method returns the internal storage object without modifying any has state.
   * The returned object should not be modified and be treated as read-only.
   *
   * Use {@link #getMutableB()} if you want to modify it.
   *
   * @return internal storage object for reading
   */
  public ProtobufMatrix getB() {
    return b;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix b = 5;</code>
   *
   * This method returns the internal storage object and sets the corresponding
   * has state. The returned object will become part of this message and its
   * contents may be modified as long as the has state is not cleared.
   *
   * @return internal storage object for modifications
   */
  public ProtobufMatrix getMutableB() {
    bitField0_ |= 0x00000010;
    return b;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix b = 5;</code>
   * @param value the b to set
   * @return this
   */
  public ProtobufLinearSystem setB(final ProtobufMatrix value) {
    bitField0_ |= 0x00000010;
    b.copyFrom(value);
    return this;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix c = 6;</code>
   * @return whether the c field is set
   */
  public boolean hasC() {
    return (bitField0_ & 0x00000020) != 0;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix c = 6;</code>
   * @return this
   */
  public ProtobufLinearSystem clearC() {
    bitField0_ &= ~0x00000020;
    c.clear();
    return this;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix c = 6;</code>
   *
   * This method returns the internal storage object without modifying any has state.
   * The returned object should not be modified and be treated as read-only.
   *
   * Use {@link #getMutableC()} if you want to modify it.
   *
   * @return internal storage object for reading
   */
  public ProtobufMatrix getC() {
    return c;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix c = 6;</code>
   *
   * This method returns the internal storage object and sets the corresponding
   * has state. The returned object will become part of this message and its
   * contents may be modified as long as the has state is not cleared.
   *
   * @return internal storage object for modifications
   */
  public ProtobufMatrix getMutableC() {
    bitField0_ |= 0x00000020;
    return c;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix c = 6;</code>
   * @param value the c to set
   * @return this
   */
  public ProtobufLinearSystem setC(final ProtobufMatrix value) {
    bitField0_ |= 0x00000020;
    c.copyFrom(value);
    return this;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix d = 7;</code>
   * @return whether the d field is set
   */
  public boolean hasD() {
    return (bitField0_ & 0x00000040) != 0;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix d = 7;</code>
   * @return this
   */
  public ProtobufLinearSystem clearD() {
    bitField0_ &= ~0x00000040;
    d.clear();
    return this;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix d = 7;</code>
   *
   * This method returns the internal storage object without modifying any has state.
   * The returned object should not be modified and be treated as read-only.
   *
   * Use {@link #getMutableD()} if you want to modify it.
   *
   * @return internal storage object for reading
   */
  public ProtobufMatrix getD() {
    return d;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix d = 7;</code>
   *
   * This method returns the internal storage object and sets the corresponding
   * has state. The returned object will become part of this message and its
   * contents may be modified as long as the has state is not cleared.
   *
   * @return internal storage object for modifications
   */
  public ProtobufMatrix getMutableD() {
    bitField0_ |= 0x00000040;
    return d;
  }

  /**
   * <code>optional .wpi.proto.ProtobufMatrix d = 7;</code>
   * @param value the d to set
   * @return this
   */
  public ProtobufLinearSystem setD(final ProtobufMatrix value) {
    bitField0_ |= 0x00000040;
    d.copyFrom(value);
    return this;
  }

  @Override
  public ProtobufLinearSystem copyFrom(final ProtobufLinearSystem other) {
    cachedSize = other.cachedSize;
    if ((bitField0_ | other.bitField0_) != 0) {
      bitField0_ = other.bitField0_;
      numStates = other.numStates;
      numInputs = other.numInputs;
      numOutputs = other.numOutputs;
      a.copyFrom(other.a);
      b.copyFrom(other.b);
      c.copyFrom(other.c);
      d.copyFrom(other.d);
    }
    return this;
  }

  @Override
  public ProtobufLinearSystem mergeFrom(final ProtobufLinearSystem other) {
    if (other.isEmpty()) {
      return this;
    }
    cachedSize = -1;
    if (other.hasNumStates()) {
      setNumStates(other.numStates);
    }
    if (other.hasNumInputs()) {
      setNumInputs(other.numInputs);
    }
    if (other.hasNumOutputs()) {
      setNumOutputs(other.numOutputs);
    }
    if (other.hasA()) {
      getMutableA().mergeFrom(other.a);
    }
    if (other.hasB()) {
      getMutableB().mergeFrom(other.b);
    }
    if (other.hasC()) {
      getMutableC().mergeFrom(other.c);
    }
    if (other.hasD()) {
      getMutableD().mergeFrom(other.d);
    }
    return this;
  }

  @Override
  public ProtobufLinearSystem clear() {
    if (isEmpty()) {
      return this;
    }
    cachedSize = -1;
    bitField0_ = 0;
    numStates = 0;
    numInputs = 0;
    numOutputs = 0;
    a.clear();
    b.clear();
    c.clear();
    d.clear();
    return this;
  }

  @Override
  public ProtobufLinearSystem clearQuick() {
    if (isEmpty()) {
      return this;
    }
    cachedSize = -1;
    bitField0_ = 0;
    a.clearQuick();
    b.clearQuick();
    c.clearQuick();
    d.clearQuick();
    return this;
  }

  @Override
  public boolean equals(Object o) {
    if (o == this) {
      return true;
    }
    if (!(o instanceof ProtobufLinearSystem)) {
      return false;
    }
    ProtobufLinearSystem other = (ProtobufLinearSystem) o;
    return bitField0_ == other.bitField0_
      && (!hasNumStates() || numStates == other.numStates)
      && (!hasNumInputs() || numInputs == other.numInputs)
      && (!hasNumOutputs() || numOutputs == other.numOutputs)
      && (!hasA() || a.equals(other.a))
      && (!hasB() || b.equals(other.b))
      && (!hasC() || c.equals(other.c))
      && (!hasD() || d.equals(other.d));
  }

  @Override
  public void writeTo(final ProtoSink output) throws IOException {
    if ((bitField0_ & 0x00000001) != 0) {
      output.writeRawByte((byte) 8);
      output.writeUInt32NoTag(numStates);
    }
    if ((bitField0_ & 0x00000002) != 0) {
      output.writeRawByte((byte) 16);
      output.writeUInt32NoTag(numInputs);
    }
    if ((bitField0_ & 0x00000004) != 0) {
      output.writeRawByte((byte) 24);
      output.writeUInt32NoTag(numOutputs);
    }
    if ((bitField0_ & 0x00000008) != 0) {
      output.writeRawByte((byte) 34);
      output.writeMessageNoTag(a);
    }
    if ((bitField0_ & 0x00000010) != 0) {
      output.writeRawByte((byte) 42);
      output.writeMessageNoTag(b);
    }
    if ((bitField0_ & 0x00000020) != 0) {
      output.writeRawByte((byte) 50);
      output.writeMessageNoTag(c);
    }
    if ((bitField0_ & 0x00000040) != 0) {
      output.writeRawByte((byte) 58);
      output.writeMessageNoTag(d);
    }
  }

  @Override
  protected int computeSerializedSize() {
    int size = 0;
    if ((bitField0_ & 0x00000001) != 0) {
      size += 1 + ProtoSink.computeUInt32SizeNoTag(numStates);
    }
    if ((bitField0_ & 0x00000002) != 0) {
      size += 1 + ProtoSink.computeUInt32SizeNoTag(numInputs);
    }
    if ((bitField0_ & 0x00000004) != 0) {
      size += 1 + ProtoSink.computeUInt32SizeNoTag(numOutputs);
    }
    if ((bitField0_ & 0x00000008) != 0) {
      size += 1 + ProtoSink.computeMessageSizeNoTag(a);
    }
    if ((bitField0_ & 0x00000010) != 0) {
      size += 1 + ProtoSink.computeMessageSizeNoTag(b);
    }
    if ((bitField0_ & 0x00000020) != 0) {
      size += 1 + ProtoSink.computeMessageSizeNoTag(c);
    }
    if ((bitField0_ & 0x00000040) != 0) {
      size += 1 + ProtoSink.computeMessageSizeNoTag(d);
    }
    return size;
  }

  @Override
  @SuppressWarnings("fallthrough")
  public ProtobufLinearSystem mergeFrom(final ProtoSource input) throws IOException {
    // Enabled Fall-Through Optimization (QuickBuffers)
    int tag = input.readTag();
    while (true) {
      switch (tag) {
        case 8: {
          // numStates
          numStates = input.readUInt32();
          bitField0_ |= 0x00000001;
          tag = input.readTag();
          if (tag != 16) {
            break;
          }
        }
        case 16: {
          // numInputs
          numInputs = input.readUInt32();
          bitField0_ |= 0x00000002;
          tag = input.readTag();
          if (tag != 24) {
            break;
          }
        }
        case 24: {
          // numOutputs
          numOutputs = input.readUInt32();
          bitField0_ |= 0x00000004;
          tag = input.readTag();
          if (tag != 34) {
            break;
          }
        }
        case 34: {
          // a
          input.readMessage(a);
          bitField0_ |= 0x00000008;
          tag = input.readTag();
          if (tag != 42) {
            break;
          }
        }
        case 42: {
          // b
          input.readMessage(b);
          bitField0_ |= 0x00000010;
          tag = input.readTag();
          if (tag != 50) {
            break;
          }
        }
        case 50: {
          // c
          input.readMessage(c);
          bitField0_ |= 0x00000020;
          tag = input.readTag();
          if (tag != 58) {
            break;
          }
        }
        case 58: {
          // d
          input.readMessage(d);
          bitField0_ |= 0x00000040;
          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.writeUInt32(FieldNames.numStates, numStates);
    }
    if ((bitField0_ & 0x00000002) != 0) {
      output.writeUInt32(FieldNames.numInputs, numInputs);
    }
    if ((bitField0_ & 0x00000004) != 0) {
      output.writeUInt32(FieldNames.numOutputs, numOutputs);
    }
    if ((bitField0_ & 0x00000008) != 0) {
      output.writeMessage(FieldNames.a, a);
    }
    if ((bitField0_ & 0x00000010) != 0) {
      output.writeMessage(FieldNames.b, b);
    }
    if ((bitField0_ & 0x00000020) != 0) {
      output.writeMessage(FieldNames.c, c);
    }
    if ((bitField0_ & 0x00000040) != 0) {
      output.writeMessage(FieldNames.d, d);
    }
    output.endObject();
  }

  @Override
  public ProtobufLinearSystem mergeFrom(final JsonSource input) throws IOException {
    if (!input.beginObject()) {
      return this;
    }
    while (!input.isAtEnd()) {
      switch (input.readFieldHash()) {
        case 1233856808:
        case 1643330779: {
          if (input.isAtField(FieldNames.numStates)) {
            if (!input.trySkipNullValue()) {
              numStates = input.readUInt32();
              bitField0_ |= 0x00000001;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case 942472463:
        case 1351946434: {
          if (input.isAtField(FieldNames.numInputs)) {
            if (!input.trySkipNullValue()) {
              numInputs = input.readUInt32();
              bitField0_ |= 0x00000002;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case 385880364:
        case 194671577: {
          if (input.isAtField(FieldNames.numOutputs)) {
            if (!input.trySkipNullValue()) {
              numOutputs = input.readUInt32();
              bitField0_ |= 0x00000004;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case 97: {
          if (input.isAtField(FieldNames.a)) {
            if (!input.trySkipNullValue()) {
              input.readMessage(a);
              bitField0_ |= 0x00000008;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case 98: {
          if (input.isAtField(FieldNames.b)) {
            if (!input.trySkipNullValue()) {
              input.readMessage(b);
              bitField0_ |= 0x00000010;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case 99: {
          if (input.isAtField(FieldNames.c)) {
            if (!input.trySkipNullValue()) {
              input.readMessage(c);
              bitField0_ |= 0x00000020;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case 100: {
          if (input.isAtField(FieldNames.d)) {
            if (!input.trySkipNullValue()) {
              input.readMessage(d);
              bitField0_ |= 0x00000040;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        default: {
          input.skipUnknownField();
          break;
        }
      }
    }
    input.endObject();
    return this;
  }

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

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

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

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

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

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

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

  private enum ProtobufLinearSystemFactory implements MessageFactory<ProtobufLinearSystem> {
    INSTANCE;

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

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

    static final FieldName numInputs = FieldName.forField("numInputs", "num_inputs");

    static final FieldName numOutputs = FieldName.forField("numOutputs", "num_outputs");

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

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

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

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