// 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 RelicSmartWearGetPlanScRspOuterClass {
  /**
   * Protobuf type {@code RelicSmartWearGetPlanScRsp}
   */
  public static final class RelicSmartWearGetPlanScRsp extends ProtoMessage<RelicSmartWearGetPlanScRsp> implements Cloneable {
    private static final long serialVersionUID = 0L;

    /**
     * <code>optional uint32 avatar_id = 3;</code>
     */
    private int avatarId;

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

    /**
     * <code>repeated .RelicSmartSuitPlan plan_list = 11;</code>
     */
    private final RepeatedMessage<RelicSmartSuitPlanOuterClass.RelicSmartSuitPlan> planList = RepeatedMessage.newEmptyInstance(RelicSmartSuitPlanOuterClass.RelicSmartSuitPlan.getFactory());

    private RelicSmartWearGetPlanScRsp() {
    }

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

    /**
     * <code>optional uint32 avatar_id = 3;</code>
     * @return whether the avatarId field is set
     */
    public boolean hasAvatarId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 avatar_id = 3;</code>
     * @return this
     */
    public RelicSmartWearGetPlanScRsp clearAvatarId() {
      bitField0_ &= ~0x00000001;
      avatarId = 0;
      return this;
    }

    /**
     * <code>optional uint32 avatar_id = 3;</code>
     * @return the avatarId
     */
    public int getAvatarId() {
      return avatarId;
    }

    /**
     * <code>optional uint32 avatar_id = 3;</code>
     * @param value the avatarId to set
     * @return this
     */
    public RelicSmartWearGetPlanScRsp setAvatarId(final int value) {
      bitField0_ |= 0x00000001;
      avatarId = value;
      return this;
    }

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

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

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

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

    /**
     * <code>repeated .RelicSmartSuitPlan plan_list = 11;</code>
     * @return whether the planList field is set
     */
    public boolean hasPlanList() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>repeated .RelicSmartSuitPlan plan_list = 11;</code>
     * @return this
     */
    public RelicSmartWearGetPlanScRsp clearPlanList() {
      bitField0_ &= ~0x00000004;
      planList.clear();
      return this;
    }

    /**
     * <code>repeated .RelicSmartSuitPlan plan_list = 11;</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 #getMutablePlanList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<RelicSmartSuitPlanOuterClass.RelicSmartSuitPlan> getPlanList() {
      return planList;
    }

    /**
     * <code>repeated .RelicSmartSuitPlan plan_list = 11;</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<RelicSmartSuitPlanOuterClass.RelicSmartSuitPlan> getMutablePlanList() {
      bitField0_ |= 0x00000004;
      return planList;
    }

    /**
     * <code>repeated .RelicSmartSuitPlan plan_list = 11;</code>
     * @param value the planList to add
     * @return this
     */
    public RelicSmartWearGetPlanScRsp addPlanList(
        final RelicSmartSuitPlanOuterClass.RelicSmartSuitPlan value) {
      bitField0_ |= 0x00000004;
      planList.add(value);
      return this;
    }

    /**
     * <code>repeated .RelicSmartSuitPlan plan_list = 11;</code>
     * @param values the planList to add
     * @return this
     */
    public RelicSmartWearGetPlanScRsp addAllPlanList(
        final RelicSmartSuitPlanOuterClass.RelicSmartSuitPlan... values) {
      bitField0_ |= 0x00000004;
      planList.addAll(values);
      return this;
    }

    @Override
    public RelicSmartWearGetPlanScRsp copyFrom(final RelicSmartWearGetPlanScRsp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        avatarId = other.avatarId;
        retcode = other.retcode;
        planList.copyFrom(other.planList);
      }
      return this;
    }

    @Override
    public RelicSmartWearGetPlanScRsp mergeFrom(final RelicSmartWearGetPlanScRsp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasAvatarId()) {
        setAvatarId(other.avatarId);
      }
      if (other.hasRetcode()) {
        setRetcode(other.retcode);
      }
      if (other.hasPlanList()) {
        getMutablePlanList().addAll(other.planList);
      }
      return this;
    }

    @Override
    public RelicSmartWearGetPlanScRsp clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      avatarId = 0;
      retcode = 0;
      planList.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof RelicSmartWearGetPlanScRsp)) {
        return false;
      }
      RelicSmartWearGetPlanScRsp other = (RelicSmartWearGetPlanScRsp) o;
      return bitField0_ == other.bitField0_
        && (!hasAvatarId() || avatarId == other.avatarId)
        && (!hasRetcode() || retcode == other.retcode)
        && (!hasPlanList() || planList.equals(other.planList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 24);
        output.writeUInt32NoTag(avatarId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 32);
        output.writeUInt32NoTag(retcode);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        for (int i = 0; i < planList.length(); i++) {
          output.writeRawByte((byte) 90);
          output.writeMessageNoTag(planList.get(i));
        }
      }
    }

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

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

    @Override
    public RelicSmartWearGetPlanScRsp mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1787287636:
          case -428636735: {
            if (input.isAtField(FieldNames.avatarId)) {
              if (!input.trySkipNullValue()) {
                avatarId = 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 1868362599:
          case 2102292468: {
            if (input.isAtField(FieldNames.planList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(planList);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum RelicSmartWearGetPlanScRspFactory implements MessageFactory<RelicSmartWearGetPlanScRsp> {
      INSTANCE;

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

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

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

      static final FieldName planList = FieldName.forField("planList", "plan_list");
    }
  }
}
