// Code generated by protocol buffer compiler. Do not edit!
package emu.nebula.proto;

import java.io.IOException;
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.RepeatedByte;

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

    /**
     * <code>optional uint64 Checksum = 4;</code>
     */
    private long checksum;

    /**
     * <code>optional uint32 Time = 1;</code>
     */
    private int time;

    /**
     * <code>optional uint32 Damage = 2;</code>
     */
    private int damage;

    /**
     * <code>optional .TravelerDuelBattleSamples sample = 3;</code>
     */
    private final TravelerDuelRankUpload.TravelerDuelBattleSamples sample = TravelerDuelRankUpload.TravelerDuelBattleSamples.newInstance();

    /**
     * <code>optional .Events Events = 7;</code>
     */
    private final Public.Events events = Public.Events.newInstance();

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     */
    private final RepeatedByte nextPackage = RepeatedByte.newEmptyInstance();

    private JointDrillSettleReq() {
    }

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

    /**
     * <code>optional uint64 Checksum = 4;</code>
     * @return whether the checksum field is set
     */
    public boolean hasChecksum() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint64 Checksum = 4;</code>
     * @return this
     */
    public JointDrillSettleReq clearChecksum() {
      bitField0_ &= ~0x00000001;
      checksum = 0L;
      return this;
    }

    /**
     * <code>optional uint64 Checksum = 4;</code>
     * @return the checksum
     */
    public long getChecksum() {
      return checksum;
    }

    /**
     * <code>optional uint64 Checksum = 4;</code>
     * @param value the checksum to set
     * @return this
     */
    public JointDrillSettleReq setChecksum(final long value) {
      bitField0_ |= 0x00000001;
      checksum = value;
      return this;
    }

    /**
     * <code>optional uint32 Time = 1;</code>
     * @return whether the time field is set
     */
    public boolean hasTime() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 Time = 1;</code>
     * @return this
     */
    public JointDrillSettleReq clearTime() {
      bitField0_ &= ~0x00000002;
      time = 0;
      return this;
    }

    /**
     * <code>optional uint32 Time = 1;</code>
     * @return the time
     */
    public int getTime() {
      return time;
    }

    /**
     * <code>optional uint32 Time = 1;</code>
     * @param value the time to set
     * @return this
     */
    public JointDrillSettleReq setTime(final int value) {
      bitField0_ |= 0x00000002;
      time = value;
      return this;
    }

    /**
     * <code>optional uint32 Damage = 2;</code>
     * @return whether the damage field is set
     */
    public boolean hasDamage() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional uint32 Damage = 2;</code>
     * @return this
     */
    public JointDrillSettleReq clearDamage() {
      bitField0_ &= ~0x00000004;
      damage = 0;
      return this;
    }

    /**
     * <code>optional uint32 Damage = 2;</code>
     * @return the damage
     */
    public int getDamage() {
      return damage;
    }

    /**
     * <code>optional uint32 Damage = 2;</code>
     * @param value the damage to set
     * @return this
     */
    public JointDrillSettleReq setDamage(final int value) {
      bitField0_ |= 0x00000004;
      damage = value;
      return this;
    }

    /**
     * <code>optional .TravelerDuelBattleSamples sample = 3;</code>
     * @return whether the sample field is set
     */
    public boolean hasSample() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional .TravelerDuelBattleSamples sample = 3;</code>
     * @return this
     */
    public JointDrillSettleReq clearSample() {
      bitField0_ &= ~0x00000008;
      sample.clear();
      return this;
    }

    /**
     * <code>optional .TravelerDuelBattleSamples sample = 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 #getMutableSample()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public TravelerDuelRankUpload.TravelerDuelBattleSamples getSample() {
      return sample;
    }

    /**
     * <code>optional .TravelerDuelBattleSamples sample = 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 TravelerDuelRankUpload.TravelerDuelBattleSamples getMutableSample() {
      bitField0_ |= 0x00000008;
      return sample;
    }

    /**
     * <code>optional .TravelerDuelBattleSamples sample = 3;</code>
     * @param value the sample to set
     * @return this
     */
    public JointDrillSettleReq setSample(
        final TravelerDuelRankUpload.TravelerDuelBattleSamples value) {
      bitField0_ |= 0x00000008;
      sample.copyFrom(value);
      return this;
    }

    /**
     * <code>optional .Events Events = 7;</code>
     * @return whether the events field is set
     */
    public boolean hasEvents() {
      return (bitField0_ & 0x00000010) != 0;
    }

    /**
     * <code>optional .Events Events = 7;</code>
     * @return this
     */
    public JointDrillSettleReq clearEvents() {
      bitField0_ &= ~0x00000010;
      events.clear();
      return this;
    }

    /**
     * <code>optional .Events Events = 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 #getMutableEvents()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public Public.Events getEvents() {
      return events;
    }

    /**
     * <code>optional .Events Events = 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 Public.Events getMutableEvents() {
      bitField0_ |= 0x00000010;
      return events;
    }

    /**
     * <code>optional .Events Events = 7;</code>
     * @param value the events to set
     * @return this
     */
    public JointDrillSettleReq setEvents(final Public.Events value) {
      bitField0_ |= 0x00000010;
      events.copyFrom(value);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return whether the nextPackage field is set
     */
    public boolean hasNextPackage() {
      return (bitField0_ & 0x00000020) != 0;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return this
     */
    public JointDrillSettleReq clearNextPackage() {
      bitField0_ &= ~0x00000020;
      nextPackage.clear();
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</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 #getMutableNextPackage()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedByte getNextPackage() {
      return nextPackage;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</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 RepeatedByte getMutableNextPackage() {
      bitField0_ |= 0x00000020;
      return nextPackage;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param value the nextPackage to add
     * @return this
     */
    public JointDrillSettleReq addNextPackage(final byte value) {
      bitField0_ |= 0x00000020;
      nextPackage.add(value);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param values the nextPackage to add
     * @return this
     */
    public JointDrillSettleReq addAllNextPackage(final byte... values) {
      bitField0_ |= 0x00000020;
      nextPackage.addAll(values);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param values the nextPackage to set
     * @return this
     */
    public JointDrillSettleReq setNextPackage(final byte... values) {
      bitField0_ |= 0x00000020;
      nextPackage.copyFrom(values);
      return this;
    }

    @Override
    public JointDrillSettleReq copyFrom(final JointDrillSettleReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        checksum = other.checksum;
        time = other.time;
        damage = other.damage;
        sample.copyFrom(other.sample);
        events.copyFrom(other.events);
        nextPackage.copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public JointDrillSettleReq mergeFrom(final JointDrillSettleReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasChecksum()) {
        setChecksum(other.checksum);
      }
      if (other.hasTime()) {
        setTime(other.time);
      }
      if (other.hasDamage()) {
        setDamage(other.damage);
      }
      if (other.hasSample()) {
        getMutableSample().mergeFrom(other.sample);
      }
      if (other.hasEvents()) {
        getMutableEvents().mergeFrom(other.events);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public JointDrillSettleReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      checksum = 0L;
      time = 0;
      damage = 0;
      sample.clear();
      events.clear();
      nextPackage.clear();
      return this;
    }

    @Override
    public JointDrillSettleReq clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      sample.clearQuick();
      events.clearQuick();
      nextPackage.clear();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof JointDrillSettleReq)) {
        return false;
      }
      JointDrillSettleReq other = (JointDrillSettleReq) o;
      return bitField0_ == other.bitField0_
        && (!hasChecksum() || checksum == other.checksum)
        && (!hasTime() || time == other.time)
        && (!hasDamage() || damage == other.damage)
        && (!hasSample() || sample.equals(other.sample))
        && (!hasEvents() || events.equals(other.events))
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 32);
        output.writeUInt64NoTag(checksum);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 8);
        output.writeUInt32NoTag(time);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(damage);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 26);
        output.writeMessageNoTag(sample);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRawByte((byte) 58);
        output.writeMessageNoTag(events);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt64SizeNoTag(checksum);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(time);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(damage);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(sample);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(events);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public JointDrillSettleReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 32: {
            // checksum
            checksum = input.readUInt64();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 8) {
              break;
            }
          }
          case 8: {
            // time
            time = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 16) {
              break;
            }
          }
          case 16: {
            // damage
            damage = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 26) {
              break;
            }
          }
          case 26: {
            // sample
            input.readMessage(sample);
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 58) {
              break;
            }
          }
          case 58: {
            // events
            input.readMessage(events);
            bitField0_ |= 0x00000010;
            tag = input.readTag();
            if (tag != 16378) {
              break;
            }
          }
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            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.writeUInt64(FieldNames.checksum, checksum);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.time, time);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.damage, damage);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeMessage(FieldNames.sample, sample);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeMessage(FieldNames.events, events);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      output.endObject();
    }

    @Override
    public JointDrillSettleReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1601552483: {
            if (input.isAtField(FieldNames.checksum)) {
              if (!input.trySkipNullValue()) {
                checksum = input.readUInt64();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2606829: {
            if (input.isAtField(FieldNames.time)) {
              if (!input.trySkipNullValue()) {
                time = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2039707535: {
            if (input.isAtField(FieldNames.damage)) {
              if (!input.trySkipNullValue()) {
                damage = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -909675094: {
            if (input.isAtField(FieldNames.sample)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(sample);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2087505209: {
            if (input.isAtField(FieldNames.events)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(events);
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000020;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum JointDrillSettleReqFactory implements MessageFactory<JointDrillSettleReq> {
      INSTANCE;

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

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

      static final FieldName time = FieldName.forField("Time");

      static final FieldName damage = FieldName.forField("Damage");

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

      static final FieldName events = FieldName.forField("Events");

      static final FieldName nextPackage = FieldName.forField("NextPackage");
    }
  }
}
