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

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

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

    /**
     * <code>optional .VampireClientData ClientData = 6;</code>
     */
    private final Public.VampireClientData clientData = Public.VampireClientData.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();

    /**
     * <code>repeated uint32 KillCount = 1;</code>
     */
    private final RepeatedInt killCount = RepeatedInt.newEmptyInstance();

    private VampireSurvivorAreaChangeReq() {
    }

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

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

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

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

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

    /**
     * <code>optional .VampireClientData ClientData = 6;</code>
     * @return whether the clientData field is set
     */
    public boolean hasClientData() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional .VampireClientData ClientData = 6;</code>
     * @return this
     */
    public VampireSurvivorAreaChangeReq clearClientData() {
      bitField0_ &= ~0x00000002;
      clientData.clear();
      return this;
    }

    /**
     * <code>optional .VampireClientData ClientData = 6;</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 #getMutableClientData()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public Public.VampireClientData getClientData() {
      return clientData;
    }

    /**
     * <code>optional .VampireClientData ClientData = 6;</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.VampireClientData getMutableClientData() {
      bitField0_ |= 0x00000002;
      return clientData;
    }

    /**
     * <code>optional .VampireClientData ClientData = 6;</code>
     * @param value the clientData to set
     * @return this
     */
    public VampireSurvivorAreaChangeReq setClientData(final Public.VampireClientData value) {
      bitField0_ |= 0x00000002;
      clientData.copyFrom(value);
      return this;
    }

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

    /**
     * <code>optional .Events Events = 7;</code>
     * @return this
     */
    public VampireSurvivorAreaChangeReq clearEvents() {
      bitField0_ &= ~0x00000004;
      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_ |= 0x00000004;
      return events;
    }

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

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

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return this
     */
    public VampireSurvivorAreaChangeReq clearNextPackage() {
      bitField0_ &= ~0x00000008;
      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_ |= 0x00000008;
      return nextPackage;
    }

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

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

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

    /**
     * <code>repeated uint32 KillCount = 1;</code>
     * @return whether the killCount field is set
     */
    public boolean hasKillCount() {
      return (bitField0_ & 0x00000010) != 0;
    }

    /**
     * <code>repeated uint32 KillCount = 1;</code>
     * @return this
     */
    public VampireSurvivorAreaChangeReq clearKillCount() {
      bitField0_ &= ~0x00000010;
      killCount.clear();
      return this;
    }

    /**
     * <code>repeated uint32 KillCount = 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 #getMutableKillCount()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedInt getKillCount() {
      return killCount;
    }

    /**
     * <code>repeated uint32 KillCount = 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 RepeatedInt getMutableKillCount() {
      bitField0_ |= 0x00000010;
      return killCount;
    }

    /**
     * <code>repeated uint32 KillCount = 1;</code>
     * @param value the killCount to add
     * @return this
     */
    public VampireSurvivorAreaChangeReq addKillCount(final int value) {
      bitField0_ |= 0x00000010;
      killCount.add(value);
      return this;
    }

    /**
     * <code>repeated uint32 KillCount = 1;</code>
     * @param values the killCount to add
     * @return this
     */
    public VampireSurvivorAreaChangeReq addAllKillCount(final int... values) {
      bitField0_ |= 0x00000010;
      killCount.addAll(values);
      return this;
    }

    @Override
    public VampireSurvivorAreaChangeReq copyFrom(final VampireSurvivorAreaChangeReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        time = other.time;
        clientData.copyFrom(other.clientData);
        events.copyFrom(other.events);
        nextPackage.copyFrom(other.nextPackage);
        killCount.copyFrom(other.killCount);
      }
      return this;
    }

    @Override
    public VampireSurvivorAreaChangeReq mergeFrom(final VampireSurvivorAreaChangeReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasTime()) {
        setTime(other.time);
      }
      if (other.hasClientData()) {
        getMutableClientData().mergeFrom(other.clientData);
      }
      if (other.hasEvents()) {
        getMutableEvents().mergeFrom(other.events);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      if (other.hasKillCount()) {
        getMutableKillCount().addAll(other.killCount);
      }
      return this;
    }

    @Override
    public VampireSurvivorAreaChangeReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      time = 0;
      clientData.clear();
      events.clear();
      nextPackage.clear();
      killCount.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof VampireSurvivorAreaChangeReq)) {
        return false;
      }
      VampireSurvivorAreaChangeReq other = (VampireSurvivorAreaChangeReq) o;
      return bitField0_ == other.bitField0_
        && (!hasTime() || time == other.time)
        && (!hasClientData() || clientData.equals(other.clientData))
        && (!hasEvents() || events.equals(other.events))
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage))
        && (!hasKillCount() || killCount.equals(other.killCount));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(time);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 50);
        output.writeMessageNoTag(clientData);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 58);
        output.writeMessageNoTag(events);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        for (int i = 0; i < killCount.length(); i++) {
          output.writeRawByte((byte) 8);
          output.writeUInt32NoTag(killCount.array()[i]);
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(time);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(clientData);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(events);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += (1 * killCount.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(killCount);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public VampireSurvivorAreaChangeReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 16: {
            // time
            time = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 50) {
              break;
            }
          }
          case 50: {
            // clientData
            input.readMessage(clientData);
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 58) {
              break;
            }
          }
          case 58: {
            // events
            input.readMessage(events);
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 16378) {
              break;
            }
          }
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 10) {
              break;
            }
          }
          case 10: {
            // killCount [packed=true]
            input.readPackedUInt32(killCount, tag);
            bitField0_ |= 0x00000010;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
          case 8: {
            // killCount [packed=false]
            tag = input.readRepeatedUInt32(killCount, tag);
            bitField0_ |= 0x00000010;
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeUInt32(FieldNames.time, time);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeMessage(FieldNames.clientData, clientData);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeMessage(FieldNames.events, events);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRepeatedUInt32(FieldNames.killCount, killCount);
      }
      output.endObject();
    }

    @Override
    public VampireSurvivorAreaChangeReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 2606829: {
            if (input.isAtField(FieldNames.time)) {
              if (!input.trySkipNullValue()) {
                time = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1199548875: {
            if (input.isAtField(FieldNames.clientData)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(clientData);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2087505209: {
            if (input.isAtField(FieldNames.events)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(events);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 414756913: {
            if (input.isAtField(FieldNames.killCount)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedUInt32(killCount);
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum VampireSurvivorAreaChangeReqFactory implements MessageFactory<VampireSurvivorAreaChangeReq> {
      INSTANCE;

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

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

      static final FieldName clientData = FieldName.forField("ClientData");

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

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

      static final FieldName killCount = FieldName.forField("KillCount");
    }
  }
}
