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

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d front_left = 1;</code>
   */
  private final ProtobufTranslation2d frontLeft = ProtobufTranslation2d.newInstance();

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d front_right = 2;</code>
   */
  private final ProtobufTranslation2d frontRight = ProtobufTranslation2d.newInstance();

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d rear_left = 3;</code>
   */
  private final ProtobufTranslation2d rearLeft = ProtobufTranslation2d.newInstance();

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d rear_right = 4;</code>
   */
  private final ProtobufTranslation2d rearRight = ProtobufTranslation2d.newInstance();

  private ProtobufMecanumDriveKinematics() {
  }

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

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d front_left = 1;</code>
   * @return whether the frontLeft field is set
   */
  public boolean hasFrontLeft() {
    return (bitField0_ & 0x00000001) != 0;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d front_left = 1;</code>
   * @return this
   */
  public ProtobufMecanumDriveKinematics clearFrontLeft() {
    bitField0_ &= ~0x00000001;
    frontLeft.clear();
    return this;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d front_left = 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 #getMutableFrontLeft()} if you want to modify it.
   *
   * @return internal storage object for reading
   */
  public ProtobufTranslation2d getFrontLeft() {
    return frontLeft;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d front_left = 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 ProtobufTranslation2d getMutableFrontLeft() {
    bitField0_ |= 0x00000001;
    return frontLeft;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d front_left = 1;</code>
   * @param value the frontLeft to set
   * @return this
   */
  public ProtobufMecanumDriveKinematics setFrontLeft(final ProtobufTranslation2d value) {
    bitField0_ |= 0x00000001;
    frontLeft.copyFrom(value);
    return this;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d front_right = 2;</code>
   * @return whether the frontRight field is set
   */
  public boolean hasFrontRight() {
    return (bitField0_ & 0x00000002) != 0;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d front_right = 2;</code>
   * @return this
   */
  public ProtobufMecanumDriveKinematics clearFrontRight() {
    bitField0_ &= ~0x00000002;
    frontRight.clear();
    return this;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d front_right = 2;</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 #getMutableFrontRight()} if you want to modify it.
   *
   * @return internal storage object for reading
   */
  public ProtobufTranslation2d getFrontRight() {
    return frontRight;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d front_right = 2;</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 ProtobufTranslation2d getMutableFrontRight() {
    bitField0_ |= 0x00000002;
    return frontRight;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d front_right = 2;</code>
   * @param value the frontRight to set
   * @return this
   */
  public ProtobufMecanumDriveKinematics setFrontRight(final ProtobufTranslation2d value) {
    bitField0_ |= 0x00000002;
    frontRight.copyFrom(value);
    return this;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d rear_left = 3;</code>
   * @return whether the rearLeft field is set
   */
  public boolean hasRearLeft() {
    return (bitField0_ & 0x00000004) != 0;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d rear_left = 3;</code>
   * @return this
   */
  public ProtobufMecanumDriveKinematics clearRearLeft() {
    bitField0_ &= ~0x00000004;
    rearLeft.clear();
    return this;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d rear_left = 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 #getMutableRearLeft()} if you want to modify it.
   *
   * @return internal storage object for reading
   */
  public ProtobufTranslation2d getRearLeft() {
    return rearLeft;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d rear_left = 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 ProtobufTranslation2d getMutableRearLeft() {
    bitField0_ |= 0x00000004;
    return rearLeft;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d rear_left = 3;</code>
   * @param value the rearLeft to set
   * @return this
   */
  public ProtobufMecanumDriveKinematics setRearLeft(final ProtobufTranslation2d value) {
    bitField0_ |= 0x00000004;
    rearLeft.copyFrom(value);
    return this;
  }

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

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d rear_right = 4;</code>
   * @return this
   */
  public ProtobufMecanumDriveKinematics clearRearRight() {
    bitField0_ &= ~0x00000008;
    rearRight.clear();
    return this;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d rear_right = 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 #getMutableRearRight()} if you want to modify it.
   *
   * @return internal storage object for reading
   */
  public ProtobufTranslation2d getRearRight() {
    return rearRight;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d rear_right = 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 ProtobufTranslation2d getMutableRearRight() {
    bitField0_ |= 0x00000008;
    return rearRight;
  }

  /**
   * <code>optional .wpi.proto.ProtobufTranslation2d rear_right = 4;</code>
   * @param value the rearRight to set
   * @return this
   */
  public ProtobufMecanumDriveKinematics setRearRight(final ProtobufTranslation2d value) {
    bitField0_ |= 0x00000008;
    rearRight.copyFrom(value);
    return this;
  }

  @Override
  public ProtobufMecanumDriveKinematics copyFrom(final ProtobufMecanumDriveKinematics other) {
    cachedSize = other.cachedSize;
    if ((bitField0_ | other.bitField0_) != 0) {
      bitField0_ = other.bitField0_;
      frontLeft.copyFrom(other.frontLeft);
      frontRight.copyFrom(other.frontRight);
      rearLeft.copyFrom(other.rearLeft);
      rearRight.copyFrom(other.rearRight);
    }
    return this;
  }

  @Override
  public ProtobufMecanumDriveKinematics mergeFrom(final ProtobufMecanumDriveKinematics other) {
    if (other.isEmpty()) {
      return this;
    }
    cachedSize = -1;
    if (other.hasFrontLeft()) {
      getMutableFrontLeft().mergeFrom(other.frontLeft);
    }
    if (other.hasFrontRight()) {
      getMutableFrontRight().mergeFrom(other.frontRight);
    }
    if (other.hasRearLeft()) {
      getMutableRearLeft().mergeFrom(other.rearLeft);
    }
    if (other.hasRearRight()) {
      getMutableRearRight().mergeFrom(other.rearRight);
    }
    return this;
  }

  @Override
  public ProtobufMecanumDriveKinematics clear() {
    if (isEmpty()) {
      return this;
    }
    cachedSize = -1;
    bitField0_ = 0;
    frontLeft.clear();
    frontRight.clear();
    rearLeft.clear();
    rearRight.clear();
    return this;
  }

  @Override
  public ProtobufMecanumDriveKinematics clearQuick() {
    if (isEmpty()) {
      return this;
    }
    cachedSize = -1;
    bitField0_ = 0;
    frontLeft.clearQuick();
    frontRight.clearQuick();
    rearLeft.clearQuick();
    rearRight.clearQuick();
    return this;
  }

  @Override
  public boolean equals(Object o) {
    if (o == this) {
      return true;
    }
    if (!(o instanceof ProtobufMecanumDriveKinematics)) {
      return false;
    }
    ProtobufMecanumDriveKinematics other = (ProtobufMecanumDriveKinematics) o;
    return bitField0_ == other.bitField0_
      && (!hasFrontLeft() || frontLeft.equals(other.frontLeft))
      && (!hasFrontRight() || frontRight.equals(other.frontRight))
      && (!hasRearLeft() || rearLeft.equals(other.rearLeft))
      && (!hasRearRight() || rearRight.equals(other.rearRight));
  }

  @Override
  public void writeTo(final ProtoSink output) throws IOException {
    if ((bitField0_ & 0x00000001) != 0) {
      output.writeRawByte((byte) 10);
      output.writeMessageNoTag(frontLeft);
    }
    if ((bitField0_ & 0x00000002) != 0) {
      output.writeRawByte((byte) 18);
      output.writeMessageNoTag(frontRight);
    }
    if ((bitField0_ & 0x00000004) != 0) {
      output.writeRawByte((byte) 26);
      output.writeMessageNoTag(rearLeft);
    }
    if ((bitField0_ & 0x00000008) != 0) {
      output.writeRawByte((byte) 34);
      output.writeMessageNoTag(rearRight);
    }
  }

  @Override
  protected int computeSerializedSize() {
    int size = 0;
    if ((bitField0_ & 0x00000001) != 0) {
      size += 1 + ProtoSink.computeMessageSizeNoTag(frontLeft);
    }
    if ((bitField0_ & 0x00000002) != 0) {
      size += 1 + ProtoSink.computeMessageSizeNoTag(frontRight);
    }
    if ((bitField0_ & 0x00000004) != 0) {
      size += 1 + ProtoSink.computeMessageSizeNoTag(rearLeft);
    }
    if ((bitField0_ & 0x00000008) != 0) {
      size += 1 + ProtoSink.computeMessageSizeNoTag(rearRight);
    }
    return size;
  }

  @Override
  @SuppressWarnings("fallthrough")
  public ProtobufMecanumDriveKinematics mergeFrom(final ProtoSource input) throws IOException {
    // Enabled Fall-Through Optimization (QuickBuffers)
    int tag = input.readTag();
    while (true) {
      switch (tag) {
        case 10: {
          // frontLeft
          input.readMessage(frontLeft);
          bitField0_ |= 0x00000001;
          tag = input.readTag();
          if (tag != 18) {
            break;
          }
        }
        case 18: {
          // frontRight
          input.readMessage(frontRight);
          bitField0_ |= 0x00000002;
          tag = input.readTag();
          if (tag != 26) {
            break;
          }
        }
        case 26: {
          // rearLeft
          input.readMessage(rearLeft);
          bitField0_ |= 0x00000004;
          tag = input.readTag();
          if (tag != 34) {
            break;
          }
        }
        case 34: {
          // rearRight
          input.readMessage(rearRight);
          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.writeMessage(FieldNames.frontLeft, frontLeft);
    }
    if ((bitField0_ & 0x00000002) != 0) {
      output.writeMessage(FieldNames.frontRight, frontRight);
    }
    if ((bitField0_ & 0x00000004) != 0) {
      output.writeMessage(FieldNames.rearLeft, rearLeft);
    }
    if ((bitField0_ & 0x00000008) != 0) {
      output.writeMessage(FieldNames.rearRight, rearRight);
    }
    output.endObject();
  }

  @Override
  public ProtobufMecanumDriveKinematics mergeFrom(final JsonSource input) throws IOException {
    if (!input.beginObject()) {
      return this;
    }
    while (!input.isAtEnd()) {
      switch (input.readFieldHash()) {
        case 127514064:
        case -324277155: {
          if (input.isAtField(FieldNames.frontLeft)) {
            if (!input.trySkipNullValue()) {
              input.readMessage(frontLeft);
              bitField0_ |= 0x00000001;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case -336370317:
        case -1456996218: {
          if (input.isAtField(FieldNames.frontRight)) {
            if (!input.trySkipNullValue()) {
              input.readMessage(frontRight);
              bitField0_ |= 0x00000002;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case -854852661:
        case -712874558: {
          if (input.isAtField(FieldNames.rearLeft)) {
            if (!input.trySkipNullValue()) {
              input.readMessage(rearLeft);
              bitField0_ |= 0x00000004;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case -724967720:
        case -618613823: {
          if (input.isAtField(FieldNames.rearRight)) {
            if (!input.trySkipNullValue()) {
              input.readMessage(rearRight);
              bitField0_ |= 0x00000008;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        default: {
          input.skipUnknownField();
          break;
        }
      }
    }
    input.endObject();
    return this;
  }

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

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

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

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

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

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

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

  private enum ProtobufMecanumDriveKinematicsFactory implements MessageFactory<ProtobufMecanumDriveKinematics> {
    INSTANCE;

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

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

    static final FieldName frontRight = FieldName.forField("frontRight", "front_right");

    static final FieldName rearLeft = FieldName.forField("rearLeft", "rear_left");

    static final FieldName rearRight = FieldName.forField("rearRight", "rear_right");
  }
}
