// 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.RepeatedInt;

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

    /**
     * <code>optional bool is_discard = 6;</code>
     */
    private boolean isDiscard;

    /**
     * <code>repeated uint32 relic_id_list = 7;</code>
     */
    private final RepeatedInt relicIdList = RepeatedInt.newEmptyInstance();

    private DiscardRelicCsReq() {
    }

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

    /**
     * <code>optional bool is_discard = 6;</code>
     * @return whether the isDiscard field is set
     */
    public boolean hasIsDiscard() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional bool is_discard = 6;</code>
     * @return this
     */
    public DiscardRelicCsReq clearIsDiscard() {
      bitField0_ &= ~0x00000001;
      isDiscard = false;
      return this;
    }

    /**
     * <code>optional bool is_discard = 6;</code>
     * @return the isDiscard
     */
    public boolean getIsDiscard() {
      return isDiscard;
    }

    /**
     * <code>optional bool is_discard = 6;</code>
     * @param value the isDiscard to set
     * @return this
     */
    public DiscardRelicCsReq setIsDiscard(final boolean value) {
      bitField0_ |= 0x00000001;
      isDiscard = value;
      return this;
    }

    /**
     * <code>repeated uint32 relic_id_list = 7;</code>
     * @return whether the relicIdList field is set
     */
    public boolean hasRelicIdList() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>repeated uint32 relic_id_list = 7;</code>
     * @return this
     */
    public DiscardRelicCsReq clearRelicIdList() {
      bitField0_ &= ~0x00000002;
      relicIdList.clear();
      return this;
    }

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

    /**
     * <code>repeated uint32 relic_id_list = 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 RepeatedInt getMutableRelicIdList() {
      bitField0_ |= 0x00000002;
      return relicIdList;
    }

    /**
     * <code>repeated uint32 relic_id_list = 7;</code>
     * @param value the relicIdList to add
     * @return this
     */
    public DiscardRelicCsReq addRelicIdList(final int value) {
      bitField0_ |= 0x00000002;
      relicIdList.add(value);
      return this;
    }

    /**
     * <code>repeated uint32 relic_id_list = 7;</code>
     * @param values the relicIdList to add
     * @return this
     */
    public DiscardRelicCsReq addAllRelicIdList(final int... values) {
      bitField0_ |= 0x00000002;
      relicIdList.addAll(values);
      return this;
    }

    @Override
    public DiscardRelicCsReq copyFrom(final DiscardRelicCsReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        isDiscard = other.isDiscard;
        relicIdList.copyFrom(other.relicIdList);
      }
      return this;
    }

    @Override
    public DiscardRelicCsReq mergeFrom(final DiscardRelicCsReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasIsDiscard()) {
        setIsDiscard(other.isDiscard);
      }
      if (other.hasRelicIdList()) {
        getMutableRelicIdList().addAll(other.relicIdList);
      }
      return this;
    }

    @Override
    public DiscardRelicCsReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      isDiscard = false;
      relicIdList.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof DiscardRelicCsReq)) {
        return false;
      }
      DiscardRelicCsReq other = (DiscardRelicCsReq) o;
      return bitField0_ == other.bitField0_
        && (!hasIsDiscard() || isDiscard == other.isDiscard)
        && (!hasRelicIdList() || relicIdList.equals(other.relicIdList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 48);
        output.writeBoolNoTag(isDiscard);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        for (int i = 0; i < relicIdList.length(); i++) {
          output.writeRawByte((byte) 56);
          output.writeUInt32NoTag(relicIdList.array()[i]);
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 2;
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += (1 * relicIdList.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(relicIdList);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public DiscardRelicCsReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 48: {
            // isDiscard
            isDiscard = input.readBool();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 58) {
              break;
            }
          }
          case 58: {
            // relicIdList [packed=true]
            input.readPackedUInt32(relicIdList, tag);
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
          case 56: {
            // relicIdList [packed=false]
            tag = input.readRepeatedUInt32(relicIdList, tag);
            bitField0_ |= 0x00000002;
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeBool(FieldNames.isDiscard, isDiscard);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRepeatedUInt32(FieldNames.relicIdList, relicIdList);
      }
      output.endObject();
    }

    @Override
    public DiscardRelicCsReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1091588116:
          case -1123290487: {
            if (input.isAtField(FieldNames.isDiscard)) {
              if (!input.trySkipNullValue()) {
                isDiscard = input.readBool();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -833914452:
          case -2020549514: {
            if (input.isAtField(FieldNames.relicIdList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedUInt32(relicIdList);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum DiscardRelicCsReqFactory implements MessageFactory<DiscardRelicCsReq> {
      INSTANCE;

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

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

      static final FieldName relicIdList = FieldName.forField("relicIdList", "relic_id_list");
    }
  }
}
