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

  /**
   * <code>optional double front_left = 1;</code>
   */
  private double frontLeft;

  /**
   * <code>optional double front_right = 2;</code>
   */
  private double frontRight;

  /**
   * <code>optional double rear_left = 3;</code>
   */
  private double rearLeft;

  /**
   * <code>optional double rear_right = 4;</code>
   */
  private double rearRight;

  private ProtobufMecanumDriveWheelVelocities() {
  }

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

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

  /**
   * <code>optional double front_left = 1;</code>
   * @return this
   */
  public ProtobufMecanumDriveWheelVelocities clearFrontLeft() {
    bitField0_ &= ~0x00000001;
    frontLeft = 0D;
    return this;
  }

  /**
   * <code>optional double front_left = 1;</code>
   * @return the frontLeft
   */
  public double getFrontLeft() {
    return frontLeft;
  }

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

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

  /**
   * <code>optional double front_right = 2;</code>
   * @return this
   */
  public ProtobufMecanumDriveWheelVelocities clearFrontRight() {
    bitField0_ &= ~0x00000002;
    frontRight = 0D;
    return this;
  }

  /**
   * <code>optional double front_right = 2;</code>
   * @return the frontRight
   */
  public double getFrontRight() {
    return frontRight;
  }

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

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

  /**
   * <code>optional double rear_left = 3;</code>
   * @return this
   */
  public ProtobufMecanumDriveWheelVelocities clearRearLeft() {
    bitField0_ &= ~0x00000004;
    rearLeft = 0D;
    return this;
  }

  /**
   * <code>optional double rear_left = 3;</code>
   * @return the rearLeft
   */
  public double getRearLeft() {
    return rearLeft;
  }

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

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

  /**
   * <code>optional double rear_right = 4;</code>
   * @return this
   */
  public ProtobufMecanumDriveWheelVelocities clearRearRight() {
    bitField0_ &= ~0x00000008;
    rearRight = 0D;
    return this;
  }

  /**
   * <code>optional double rear_right = 4;</code>
   * @return the rearRight
   */
  public double getRearRight() {
    return rearRight;
  }

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

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

  @Override
  public ProtobufMecanumDriveWheelVelocities mergeFrom(
      final ProtobufMecanumDriveWheelVelocities other) {
    if (other.isEmpty()) {
      return this;
    }
    cachedSize = -1;
    if (other.hasFrontLeft()) {
      setFrontLeft(other.frontLeft);
    }
    if (other.hasFrontRight()) {
      setFrontRight(other.frontRight);
    }
    if (other.hasRearLeft()) {
      setRearLeft(other.rearLeft);
    }
    if (other.hasRearRight()) {
      setRearRight(other.rearRight);
    }
    return this;
  }

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

  @Override
  public ProtobufMecanumDriveWheelVelocities 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 ProtobufMecanumDriveWheelVelocities)) {
      return false;
    }
    ProtobufMecanumDriveWheelVelocities other = (ProtobufMecanumDriveWheelVelocities) o;
    return bitField0_ == other.bitField0_
      && (!hasFrontLeft() || ProtoUtil.isEqual(frontLeft, other.frontLeft))
      && (!hasFrontRight() || ProtoUtil.isEqual(frontRight, other.frontRight))
      && (!hasRearLeft() || ProtoUtil.isEqual(rearLeft, other.rearLeft))
      && (!hasRearRight() || ProtoUtil.isEqual(rearRight, other.rearRight));
  }

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

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

  @Override
  public ProtobufMecanumDriveWheelVelocities 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()) {
              frontLeft = input.readDouble();
              bitField0_ |= 0x00000001;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case -336370317:
        case -1456996218: {
          if (input.isAtField(FieldNames.frontRight)) {
            if (!input.trySkipNullValue()) {
              frontRight = input.readDouble();
              bitField0_ |= 0x00000002;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case -854852661:
        case -712874558: {
          if (input.isAtField(FieldNames.rearLeft)) {
            if (!input.trySkipNullValue()) {
              rearLeft = input.readDouble();
              bitField0_ |= 0x00000004;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case -724967720:
        case -618613823: {
          if (input.isAtField(FieldNames.rearRight)) {
            if (!input.trySkipNullValue()) {
              rearRight = input.readDouble();
              bitField0_ |= 0x00000008;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        default: {
          input.skipUnknownField();
          break;
        }
      }
    }
    input.endObject();
    return this;
  }

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

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

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

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

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

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

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

  private enum ProtobufMecanumDriveWheelVelocitiesFactory implements MessageFactory<ProtobufMecanumDriveWheelVelocities> {
    INSTANCE;

    @Override
    public ProtobufMecanumDriveWheelVelocities create() {
      return ProtobufMecanumDriveWheelVelocities.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");
  }
}
