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

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

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

    /**
     * <code>optional bool is_get_all = 11;</code>
     */
    private boolean isGetAll;

    /**
     * <code>repeated .Avatar avatar_list = 3;</code>
     */
    private final RepeatedMessage<AvatarOuterClass.Avatar> avatarList = RepeatedMessage.newEmptyInstance(AvatarOuterClass.Avatar.getFactory());

    private GetAvatarDataScRsp() {
    }

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

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

    /**
     * <code>optional uint32 retcode = 5;</code>
     * @return this
     */
    public GetAvatarDataScRsp clearRetcode() {
      bitField0_ &= ~0x00000001;
      retcode = 0;
      return this;
    }

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

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

    /**
     * <code>optional bool is_get_all = 11;</code>
     * @return whether the isGetAll field is set
     */
    public boolean hasIsGetAll() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional bool is_get_all = 11;</code>
     * @return this
     */
    public GetAvatarDataScRsp clearIsGetAll() {
      bitField0_ &= ~0x00000002;
      isGetAll = false;
      return this;
    }

    /**
     * <code>optional bool is_get_all = 11;</code>
     * @return the isGetAll
     */
    public boolean getIsGetAll() {
      return isGetAll;
    }

    /**
     * <code>optional bool is_get_all = 11;</code>
     * @param value the isGetAll to set
     * @return this
     */
    public GetAvatarDataScRsp setIsGetAll(final boolean value) {
      bitField0_ |= 0x00000002;
      isGetAll = value;
      return this;
    }

    /**
     * <code>repeated .Avatar avatar_list = 3;</code>
     * @return whether the avatarList field is set
     */
    public boolean hasAvatarList() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>repeated .Avatar avatar_list = 3;</code>
     * @return this
     */
    public GetAvatarDataScRsp clearAvatarList() {
      bitField0_ &= ~0x00000004;
      avatarList.clear();
      return this;
    }

    /**
     * <code>repeated .Avatar avatar_list = 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 #getMutableAvatarList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<AvatarOuterClass.Avatar> getAvatarList() {
      return avatarList;
    }

    /**
     * <code>repeated .Avatar avatar_list = 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 RepeatedMessage<AvatarOuterClass.Avatar> getMutableAvatarList() {
      bitField0_ |= 0x00000004;
      return avatarList;
    }

    /**
     * <code>repeated .Avatar avatar_list = 3;</code>
     * @param value the avatarList to add
     * @return this
     */
    public GetAvatarDataScRsp addAvatarList(final AvatarOuterClass.Avatar value) {
      bitField0_ |= 0x00000004;
      avatarList.add(value);
      return this;
    }

    /**
     * <code>repeated .Avatar avatar_list = 3;</code>
     * @param values the avatarList to add
     * @return this
     */
    public GetAvatarDataScRsp addAllAvatarList(final AvatarOuterClass.Avatar... values) {
      bitField0_ |= 0x00000004;
      avatarList.addAll(values);
      return this;
    }

    @Override
    public GetAvatarDataScRsp copyFrom(final GetAvatarDataScRsp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        retcode = other.retcode;
        isGetAll = other.isGetAll;
        avatarList.copyFrom(other.avatarList);
      }
      return this;
    }

    @Override
    public GetAvatarDataScRsp mergeFrom(final GetAvatarDataScRsp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasRetcode()) {
        setRetcode(other.retcode);
      }
      if (other.hasIsGetAll()) {
        setIsGetAll(other.isGetAll);
      }
      if (other.hasAvatarList()) {
        getMutableAvatarList().addAll(other.avatarList);
      }
      return this;
    }

    @Override
    public GetAvatarDataScRsp clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      retcode = 0;
      isGetAll = false;
      avatarList.clear();
      return this;
    }

    @Override
    public GetAvatarDataScRsp clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      avatarList.clearQuick();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof GetAvatarDataScRsp)) {
        return false;
      }
      GetAvatarDataScRsp other = (GetAvatarDataScRsp) o;
      return bitField0_ == other.bitField0_
        && (!hasRetcode() || retcode == other.retcode)
        && (!hasIsGetAll() || isGetAll == other.isGetAll)
        && (!hasAvatarList() || avatarList.equals(other.avatarList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 40);
        output.writeUInt32NoTag(retcode);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 88);
        output.writeBoolNoTag(isGetAll);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        for (int i = 0; i < avatarList.length(); i++) {
          output.writeRawByte((byte) 26);
          output.writeMessageNoTag(avatarList.get(i));
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 2;
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += (1 * avatarList.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(avatarList);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public GetAvatarDataScRsp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 40: {
            // retcode
            retcode = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 88) {
              break;
            }
          }
          case 88: {
            // isGetAll
            isGetAll = input.readBool();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 26) {
              break;
            }
          }
          case 26: {
            // avatarList
            tag = input.readRepeatedMessage(avatarList, tag);
            bitField0_ |= 0x00000004;
            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.retcode, retcode);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeBool(FieldNames.isGetAll, isGetAll);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRepeatedMessage(FieldNames.avatarList, avatarList);
      }
      output.endObject();
    }

    @Override
    public GetAvatarDataScRsp mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1097936398: {
            if (input.isAtField(FieldNames.retcode)) {
              if (!input.trySkipNullValue()) {
                retcode = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -575333323:
          case 1425508131: {
            if (input.isAtField(FieldNames.isGetAll)) {
              if (!input.trySkipNullValue()) {
                isGetAll = input.readBool();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -403402345:
          case 397055940: {
            if (input.isAtField(FieldNames.avatarList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(avatarList);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum GetAvatarDataScRspFactory implements MessageFactory<GetAvatarDataScRsp> {
      INSTANCE;

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

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

      static final FieldName isGetAll = FieldName.forField("isGetAll", "is_get_all");

      static final FieldName avatarList = FieldName.forField("avatarList", "avatar_list");
    }
  }
}
