// Code generated by protocol buffer compiler. Do not edit!
package emu.lunarcore.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;

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

    /**
     * <code>optional uint32 new_pet_id = 13;</code>
     */
    private int newPetId;

    /**
     * <code>optional uint32 retcode = 14;</code>
     */
    private int retcode;

    /**
     * <code>optional uint32 cur_pet_id = 15;</code>
     */
    private int curPetId;

    private SummonPetScRsp() {
    }

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

    /**
     * <code>optional uint32 new_pet_id = 13;</code>
     * @return whether the newPetId field is set
     */
    public boolean hasNewPetId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 new_pet_id = 13;</code>
     * @return this
     */
    public SummonPetScRsp clearNewPetId() {
      bitField0_ &= ~0x00000001;
      newPetId = 0;
      return this;
    }

    /**
     * <code>optional uint32 new_pet_id = 13;</code>
     * @return the newPetId
     */
    public int getNewPetId() {
      return newPetId;
    }

    /**
     * <code>optional uint32 new_pet_id = 13;</code>
     * @param value the newPetId to set
     * @return this
     */
    public SummonPetScRsp setNewPetId(final int value) {
      bitField0_ |= 0x00000001;
      newPetId = value;
      return this;
    }

    /**
     * <code>optional uint32 retcode = 14;</code>
     * @return whether the retcode field is set
     */
    public boolean hasRetcode() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 retcode = 14;</code>
     * @return this
     */
    public SummonPetScRsp clearRetcode() {
      bitField0_ &= ~0x00000002;
      retcode = 0;
      return this;
    }

    /**
     * <code>optional uint32 retcode = 14;</code>
     * @return the retcode
     */
    public int getRetcode() {
      return retcode;
    }

    /**
     * <code>optional uint32 retcode = 14;</code>
     * @param value the retcode to set
     * @return this
     */
    public SummonPetScRsp setRetcode(final int value) {
      bitField0_ |= 0x00000002;
      retcode = value;
      return this;
    }

    /**
     * <code>optional uint32 cur_pet_id = 15;</code>
     * @return whether the curPetId field is set
     */
    public boolean hasCurPetId() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional uint32 cur_pet_id = 15;</code>
     * @return this
     */
    public SummonPetScRsp clearCurPetId() {
      bitField0_ &= ~0x00000004;
      curPetId = 0;
      return this;
    }

    /**
     * <code>optional uint32 cur_pet_id = 15;</code>
     * @return the curPetId
     */
    public int getCurPetId() {
      return curPetId;
    }

    /**
     * <code>optional uint32 cur_pet_id = 15;</code>
     * @param value the curPetId to set
     * @return this
     */
    public SummonPetScRsp setCurPetId(final int value) {
      bitField0_ |= 0x00000004;
      curPetId = value;
      return this;
    }

    @Override
    public SummonPetScRsp copyFrom(final SummonPetScRsp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        newPetId = other.newPetId;
        retcode = other.retcode;
        curPetId = other.curPetId;
      }
      return this;
    }

    @Override
    public SummonPetScRsp mergeFrom(final SummonPetScRsp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasNewPetId()) {
        setNewPetId(other.newPetId);
      }
      if (other.hasRetcode()) {
        setRetcode(other.retcode);
      }
      if (other.hasCurPetId()) {
        setCurPetId(other.curPetId);
      }
      return this;
    }

    @Override
    public SummonPetScRsp clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      newPetId = 0;
      retcode = 0;
      curPetId = 0;
      return this;
    }

    @Override
    public SummonPetScRsp 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 SummonPetScRsp)) {
        return false;
      }
      SummonPetScRsp other = (SummonPetScRsp) o;
      return bitField0_ == other.bitField0_
        && (!hasNewPetId() || newPetId == other.newPetId)
        && (!hasRetcode() || retcode == other.retcode)
        && (!hasCurPetId() || curPetId == other.curPetId);
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 104);
        output.writeUInt32NoTag(newPetId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 112);
        output.writeUInt32NoTag(retcode);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 120);
        output.writeUInt32NoTag(curPetId);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(newPetId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(curPetId);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public SummonPetScRsp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 104: {
            // newPetId
            newPetId = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 112) {
              break;
            }
          }
          case 112: {
            // retcode
            retcode = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 120) {
              break;
            }
          }
          case 120: {
            // curPetId
            curPetId = input.readUInt32();
            bitField0_ |= 0x00000004;
            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.writeUInt32(FieldNames.newPetId, newPetId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.retcode, retcode);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.curPetId, curPetId);
      }
      output.endObject();
    }

    @Override
    public SummonPetScRsp mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1363040474:
          case 646870970: {
            if (input.isAtField(FieldNames.newPetId)) {
              if (!input.trySkipNullValue()) {
                newPetId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1097936398: {
            if (input.isAtField(FieldNames.retcode)) {
              if (!input.trySkipNullValue()) {
                retcode = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 544007226:
          case -465065190: {
            if (input.isAtField(FieldNames.curPetId)) {
              if (!input.trySkipNullValue()) {
                curPetId = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum SummonPetScRspFactory implements MessageFactory<SummonPetScRsp> {
      INSTANCE;

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

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

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

      static final FieldName curPetId = FieldName.forField("curPetId", "cur_pet_id");
    }
  }
}
