// 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;
import us.hebi.quickbuf.RepeatedDouble;

public final class Wpimath {
  private static final RepeatedByte descriptorData = ProtoUtil.decodeBase64(540,
    "Cg13cGltYXRoLnByb3RvEgl3cGkucHJvdG8iWgoOUHJvdG9idWZNYXRyaXgSGQoIbnVtX3Jvd3MYASAB" + 
    "KA1SB251bVJvd3MSGQoIbnVtX2NvbHMYAiABKA1SB251bUNvbHMSEgoEZGF0YRgDIAMoAVIEZGF0YSIk" + 
    "Cg5Qcm90b2J1ZlZlY3RvchISCgRyb3dzGAEgAygBUgRyb3dzQhoKGGVkdS53cGkuZmlyc3QubWF0aC5w" + 
    "cm90b0rZAgoGEgQAAA4BCggKAQwSAwAAEgoICgECEgMCABIKCAoBCBIDBAAxCgkKAggBEgMEADEKCgoC" + 
    "BAASBAYACgEKCgoDBAABEgMGCBYKCwoEBAACABIDBwIWCgwKBQQAAgAFEgMHAggKDAoFBAACAAESAwcJ" + 
    "EQoMCgUEAAIAAxIDBxQVCgsKBAQAAgESAwgCFgoMCgUEAAIBBRIDCAIICgwKBQQAAgEBEgMICREKDAoF" + 
    "BAACAQMSAwgUFQoLCgQEAAICEgMJAhsKDAoFBAACAgQSAwkCCgoMCgUEAAICBRIDCQsRCgwKBQQAAgIB" + 
    "EgMJEhYKDAoFBAACAgMSAwkZGgoKCgIEARIEDAAOAQoKCgMEAQESAwwIFgoLCgQEAQIAEgMNAhsKDAoF" + 
    "BAECAAQSAw0CCgoMCgUEAQIABRIDDQsRCgwKBQQBAgABEgMNEhYKDAoFBAECAAMSAw0ZGmIGcHJvdG8z");

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

  static final Descriptors.Descriptor wpi_proto_ProtobufMatrix_descriptor = descriptor.internalContainedType(28, 90, "ProtobufMatrix", "wpi.proto.ProtobufMatrix");

  static final Descriptors.Descriptor wpi_proto_ProtobufVector_descriptor = descriptor.internalContainedType(120, 36, "ProtobufVector", "wpi.proto.ProtobufVector");

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

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

    /**
     * <code>optional uint32 num_rows = 1;</code>
     */
    private int numRows;

    /**
     * <code>optional uint32 num_cols = 2;</code>
     */
    private int numCols;

    /**
     * <code>repeated double data = 3;</code>
     */
    private final RepeatedDouble data = RepeatedDouble.newEmptyInstance();

    private ProtobufMatrix() {
    }

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

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

    /**
     * <code>optional uint32 num_rows = 1;</code>
     * @return this
     */
    public ProtobufMatrix clearNumRows() {
      bitField0_ &= ~0x00000001;
      numRows = 0;
      return this;
    }

    /**
     * <code>optional uint32 num_rows = 1;</code>
     * @return the numRows
     */
    public int getNumRows() {
      return numRows;
    }

    /**
     * <code>optional uint32 num_rows = 1;</code>
     * @param value the numRows to set
     * @return this
     */
    public ProtobufMatrix setNumRows(final int value) {
      bitField0_ |= 0x00000001;
      numRows = value;
      return this;
    }

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

    /**
     * <code>optional uint32 num_cols = 2;</code>
     * @return this
     */
    public ProtobufMatrix clearNumCols() {
      bitField0_ &= ~0x00000002;
      numCols = 0;
      return this;
    }

    /**
     * <code>optional uint32 num_cols = 2;</code>
     * @return the numCols
     */
    public int getNumCols() {
      return numCols;
    }

    /**
     * <code>optional uint32 num_cols = 2;</code>
     * @param value the numCols to set
     * @return this
     */
    public ProtobufMatrix setNumCols(final int value) {
      bitField0_ |= 0x00000002;
      numCols = value;
      return this;
    }

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

    /**
     * <code>repeated double data = 3;</code>
     * @return this
     */
    public ProtobufMatrix clearData() {
      bitField0_ &= ~0x00000004;
      data.clear();
      return this;
    }

    /**
     * <code>repeated double data = 3;</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 #getMutableData()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedDouble getData() {
      return data;
    }

    /**
     * <code>repeated double data = 3;</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 RepeatedDouble getMutableData() {
      bitField0_ |= 0x00000004;
      return data;
    }

    /**
     * <code>repeated double data = 3;</code>
     * @param value the data to add
     * @return this
     */
    public ProtobufMatrix addData(final double value) {
      bitField0_ |= 0x00000004;
      data.add(value);
      return this;
    }

    /**
     * <code>repeated double data = 3;</code>
     * @param values the data to add
     * @return this
     */
    public ProtobufMatrix addAllData(final double... values) {
      bitField0_ |= 0x00000004;
      data.addAll(values);
      return this;
    }

    @Override
    public ProtobufMatrix copyFrom(final ProtobufMatrix other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        numRows = other.numRows;
        numCols = other.numCols;
        data.copyFrom(other.data);
      }
      return this;
    }

    @Override
    public ProtobufMatrix mergeFrom(final ProtobufMatrix other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasNumRows()) {
        setNumRows(other.numRows);
      }
      if (other.hasNumCols()) {
        setNumCols(other.numCols);
      }
      if (other.hasData()) {
        getMutableData().addAll(other.data);
      }
      return this;
    }

    @Override
    public ProtobufMatrix clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      numRows = 0;
      numCols = 0;
      data.clear();
      return this;
    }

    @Override
    public ProtobufMatrix clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      data.clear();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ProtobufMatrix)) {
        return false;
      }
      ProtobufMatrix other = (ProtobufMatrix) o;
      return bitField0_ == other.bitField0_
        && (!hasNumRows() || numRows == other.numRows)
        && (!hasNumCols() || numCols == other.numCols)
        && (!hasData() || data.equals(other.data));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 8);
        output.writeUInt32NoTag(numRows);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(numCols);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        for (int i = 0; i < data.length(); i++) {
          output.writeRawByte((byte) 25);
          output.writeDoubleNoTag(data.array()[i]);
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(numRows);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(numCols);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += (1 + 8) * data.length();
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ProtobufMatrix mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 8: {
            // numRows
            numRows = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 16) {
              break;
            }
          }
          case 16: {
            // numCols
            numCols = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 26) {
              break;
            }
          }
          case 26: {
            // data [packed=true]
            input.readPackedDouble(data);
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
          case 25: {
            // data [packed=false]
            tag = input.readRepeatedDouble(data, tag);
            bitField0_ |= 0x00000004;
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeUInt32(FieldNames.numRows, numRows);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.numCols, numCols);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRepeatedDouble(FieldNames.data, data);
      }
      output.endObject();
    }

    @Override
    public ProtobufMatrix mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -2000982401:
          case -1888824590: {
            if (input.isAtField(FieldNames.numRows)) {
              if (!input.trySkipNullValue()) {
                numRows = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2001429607:
          case -1889271796: {
            if (input.isAtField(FieldNames.numCols)) {
              if (!input.trySkipNullValue()) {
                numCols = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 3076010: {
            if (input.isAtField(FieldNames.data)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedDouble(data);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

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

    private enum ProtobufMatrixFactory implements MessageFactory<ProtobufMatrix> {
      INSTANCE;

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

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

      static final FieldName numCols = FieldName.forField("numCols", "num_cols");

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

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

    /**
     * <code>repeated double rows = 1;</code>
     */
    private final RepeatedDouble rows = RepeatedDouble.newEmptyInstance();

    private ProtobufVector() {
    }

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

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

    /**
     * <code>repeated double rows = 1;</code>
     * @return this
     */
    public ProtobufVector clearRows() {
      bitField0_ &= ~0x00000001;
      rows.clear();
      return this;
    }

    /**
     * <code>repeated double rows = 1;</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 #getMutableRows()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedDouble getRows() {
      return rows;
    }

    /**
     * <code>repeated double rows = 1;</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 RepeatedDouble getMutableRows() {
      bitField0_ |= 0x00000001;
      return rows;
    }

    /**
     * <code>repeated double rows = 1;</code>
     * @param value the rows to add
     * @return this
     */
    public ProtobufVector addRows(final double value) {
      bitField0_ |= 0x00000001;
      rows.add(value);
      return this;
    }

    /**
     * <code>repeated double rows = 1;</code>
     * @param values the rows to add
     * @return this
     */
    public ProtobufVector addAllRows(final double... values) {
      bitField0_ |= 0x00000001;
      rows.addAll(values);
      return this;
    }

    @Override
    public ProtobufVector copyFrom(final ProtobufVector other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        rows.copyFrom(other.rows);
      }
      return this;
    }

    @Override
    public ProtobufVector mergeFrom(final ProtobufVector other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasRows()) {
        getMutableRows().addAll(other.rows);
      }
      return this;
    }

    @Override
    public ProtobufVector clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      rows.clear();
      return this;
    }

    @Override
    public ProtobufVector clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      rows.clear();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ProtobufVector)) {
        return false;
      }
      ProtobufVector other = (ProtobufVector) o;
      return bitField0_ == other.bitField0_
        && (!hasRows() || rows.equals(other.rows));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        for (int i = 0; i < rows.length(); i++) {
          output.writeRawByte((byte) 9);
          output.writeDoubleNoTag(rows.array()[i]);
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += (1 + 8) * rows.length();
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ProtobufVector mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 10: {
            // rows [packed=true]
            input.readPackedDouble(rows);
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
          case 9: {
            // rows [packed=false]
            tag = input.readRepeatedDouble(rows, tag);
            bitField0_ |= 0x00000001;
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRepeatedDouble(FieldNames.rows, rows);
      }
      output.endObject();
    }

    @Override
    public ProtobufVector mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 3506649: {
            if (input.isAtField(FieldNames.rows)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedDouble(rows);
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

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

    private enum ProtobufVectorFactory implements MessageFactory<ProtobufVector> {
      INSTANCE;

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

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