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

  /**
   * <code>optional double dx = 1;</code>
   */
  private double dx;

  /**
   * <code>optional double dy = 2;</code>
   */
  private double dy;

  /**
   * <code>optional double dz = 3;</code>
   */
  private double dz;

  /**
   * <code>optional double rx = 4;</code>
   */
  private double rx;

  /**
   * <code>optional double ry = 5;</code>
   */
  private double ry;

  /**
   * <code>optional double rz = 6;</code>
   */
  private double rz;

  private ProtobufTwist3d() {
  }

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

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

  /**
   * <code>optional double dx = 1;</code>
   * @return this
   */
  public ProtobufTwist3d clearDx() {
    bitField0_ &= ~0x00000001;
    dx = 0D;
    return this;
  }

  /**
   * <code>optional double dx = 1;</code>
   * @return the dx
   */
  public double getDx() {
    return dx;
  }

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

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

  /**
   * <code>optional double dy = 2;</code>
   * @return this
   */
  public ProtobufTwist3d clearDy() {
    bitField0_ &= ~0x00000002;
    dy = 0D;
    return this;
  }

  /**
   * <code>optional double dy = 2;</code>
   * @return the dy
   */
  public double getDy() {
    return dy;
  }

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

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

  /**
   * <code>optional double dz = 3;</code>
   * @return this
   */
  public ProtobufTwist3d clearDz() {
    bitField0_ &= ~0x00000004;
    dz = 0D;
    return this;
  }

  /**
   * <code>optional double dz = 3;</code>
   * @return the dz
   */
  public double getDz() {
    return dz;
  }

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

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

  /**
   * <code>optional double rx = 4;</code>
   * @return this
   */
  public ProtobufTwist3d clearRx() {
    bitField0_ &= ~0x00000008;
    rx = 0D;
    return this;
  }

  /**
   * <code>optional double rx = 4;</code>
   * @return the rx
   */
  public double getRx() {
    return rx;
  }

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

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

  /**
   * <code>optional double ry = 5;</code>
   * @return this
   */
  public ProtobufTwist3d clearRy() {
    bitField0_ &= ~0x00000010;
    ry = 0D;
    return this;
  }

  /**
   * <code>optional double ry = 5;</code>
   * @return the ry
   */
  public double getRy() {
    return ry;
  }

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

  /**
   * <code>optional double rz = 6;</code>
   * @return whether the rz field is set
   */
  public boolean hasRz() {
    return (bitField0_ & 0x00000020) != 0;
  }

  /**
   * <code>optional double rz = 6;</code>
   * @return this
   */
  public ProtobufTwist3d clearRz() {
    bitField0_ &= ~0x00000020;
    rz = 0D;
    return this;
  }

  /**
   * <code>optional double rz = 6;</code>
   * @return the rz
   */
  public double getRz() {
    return rz;
  }

  /**
   * <code>optional double rz = 6;</code>
   * @param value the rz to set
   * @return this
   */
  public ProtobufTwist3d setRz(final double value) {
    bitField0_ |= 0x00000020;
    rz = value;
    return this;
  }

  @Override
  public ProtobufTwist3d copyFrom(final ProtobufTwist3d other) {
    cachedSize = other.cachedSize;
    if ((bitField0_ | other.bitField0_) != 0) {
      bitField0_ = other.bitField0_;
      dx = other.dx;
      dy = other.dy;
      dz = other.dz;
      rx = other.rx;
      ry = other.ry;
      rz = other.rz;
    }
    return this;
  }

  @Override
  public ProtobufTwist3d mergeFrom(final ProtobufTwist3d other) {
    if (other.isEmpty()) {
      return this;
    }
    cachedSize = -1;
    if (other.hasDx()) {
      setDx(other.dx);
    }
    if (other.hasDy()) {
      setDy(other.dy);
    }
    if (other.hasDz()) {
      setDz(other.dz);
    }
    if (other.hasRx()) {
      setRx(other.rx);
    }
    if (other.hasRy()) {
      setRy(other.ry);
    }
    if (other.hasRz()) {
      setRz(other.rz);
    }
    return this;
  }

  @Override
  public ProtobufTwist3d clear() {
    if (isEmpty()) {
      return this;
    }
    cachedSize = -1;
    bitField0_ = 0;
    dx = 0D;
    dy = 0D;
    dz = 0D;
    rx = 0D;
    ry = 0D;
    rz = 0D;
    return this;
  }

  @Override
  public ProtobufTwist3d 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 ProtobufTwist3d)) {
      return false;
    }
    ProtobufTwist3d other = (ProtobufTwist3d) o;
    return bitField0_ == other.bitField0_
      && (!hasDx() || ProtoUtil.isEqual(dx, other.dx))
      && (!hasDy() || ProtoUtil.isEqual(dy, other.dy))
      && (!hasDz() || ProtoUtil.isEqual(dz, other.dz))
      && (!hasRx() || ProtoUtil.isEqual(rx, other.rx))
      && (!hasRy() || ProtoUtil.isEqual(ry, other.ry))
      && (!hasRz() || ProtoUtil.isEqual(rz, other.rz));
  }

  @Override
  public void writeTo(final ProtoSink output) throws IOException {
    if ((bitField0_ & 0x00000001) != 0) {
      output.writeRawByte((byte) 9);
      output.writeDoubleNoTag(dx);
    }
    if ((bitField0_ & 0x00000002) != 0) {
      output.writeRawByte((byte) 17);
      output.writeDoubleNoTag(dy);
    }
    if ((bitField0_ & 0x00000004) != 0) {
      output.writeRawByte((byte) 25);
      output.writeDoubleNoTag(dz);
    }
    if ((bitField0_ & 0x00000008) != 0) {
      output.writeRawByte((byte) 33);
      output.writeDoubleNoTag(rx);
    }
    if ((bitField0_ & 0x00000010) != 0) {
      output.writeRawByte((byte) 41);
      output.writeDoubleNoTag(ry);
    }
    if ((bitField0_ & 0x00000020) != 0) {
      output.writeRawByte((byte) 49);
      output.writeDoubleNoTag(rz);
    }
  }

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

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

  @Override
  public ProtobufTwist3d mergeFrom(final JsonSource input) throws IOException {
    if (!input.beginObject()) {
      return this;
    }
    while (!input.isAtEnd()) {
      switch (input.readFieldHash()) {
        case 3220: {
          if (input.isAtField(FieldNames.dx)) {
            if (!input.trySkipNullValue()) {
              dx = input.readDouble();
              bitField0_ |= 0x00000001;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case 3221: {
          if (input.isAtField(FieldNames.dy)) {
            if (!input.trySkipNullValue()) {
              dy = input.readDouble();
              bitField0_ |= 0x00000002;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case 3222: {
          if (input.isAtField(FieldNames.dz)) {
            if (!input.trySkipNullValue()) {
              dz = input.readDouble();
              bitField0_ |= 0x00000004;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case 3654: {
          if (input.isAtField(FieldNames.rx)) {
            if (!input.trySkipNullValue()) {
              rx = input.readDouble();
              bitField0_ |= 0x00000008;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case 3655: {
          if (input.isAtField(FieldNames.ry)) {
            if (!input.trySkipNullValue()) {
              ry = input.readDouble();
              bitField0_ |= 0x00000010;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        case 3656: {
          if (input.isAtField(FieldNames.rz)) {
            if (!input.trySkipNullValue()) {
              rz = input.readDouble();
              bitField0_ |= 0x00000020;
            }
          } else {
            input.skipUnknownField();
          }
          break;
        }
        default: {
          input.skipUnknownField();
          break;
        }
      }
    }
    input.endObject();
    return this;
  }

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

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

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

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

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

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

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

  private enum ProtobufTwist3dFactory implements MessageFactory<ProtobufTwist3d> {
    INSTANCE;

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

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

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

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

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

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

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