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

    /**
     * <code>optional .ChallengeBossInfo boss_info = 11;</code>
     */
    private final ChallengeBossInfoOuterClass.ChallengeBossInfo bossInfo = ChallengeBossInfoOuterClass.ChallengeBossInfo.newInstance();

    private ChallengeExtInfo() {
    }

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

    /**
     * <code>optional .ChallengeBossInfo boss_info = 11;</code>
     * @return whether the bossInfo field is set
     */
    public boolean hasBossInfo() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional .ChallengeBossInfo boss_info = 11;</code>
     * @return this
     */
    public ChallengeExtInfo clearBossInfo() {
      bitField0_ &= ~0x00000001;
      bossInfo.clear();
      return this;
    }

    /**
     * <code>optional .ChallengeBossInfo boss_info = 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 #getMutableBossInfo()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public ChallengeBossInfoOuterClass.ChallengeBossInfo getBossInfo() {
      return bossInfo;
    }

    /**
     * <code>optional .ChallengeBossInfo boss_info = 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 ChallengeBossInfoOuterClass.ChallengeBossInfo getMutableBossInfo() {
      bitField0_ |= 0x00000001;
      return bossInfo;
    }

    /**
     * <code>optional .ChallengeBossInfo boss_info = 11;</code>
     * @param value the bossInfo to set
     * @return this
     */
    public ChallengeExtInfo setBossInfo(final ChallengeBossInfoOuterClass.ChallengeBossInfo value) {
      bitField0_ |= 0x00000001;
      bossInfo.copyFrom(value);
      return this;
    }

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

    @Override
    public ChallengeExtInfo mergeFrom(final ChallengeExtInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasBossInfo()) {
        getMutableBossInfo().mergeFrom(other.bossInfo);
      }
      return this;
    }

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ChallengeExtInfo)) {
        return false;
      }
      ChallengeExtInfo other = (ChallengeExtInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasBossInfo() || bossInfo.equals(other.bossInfo));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 90);
        output.writeMessageNoTag(bossInfo);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(bossInfo);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ChallengeExtInfo mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 90: {
            // bossInfo
            input.readMessage(bossInfo);
            bitField0_ |= 0x00000001;
            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.writeMessage(FieldNames.bossInfo, bossInfo);
      }
      output.endObject();
    }

    @Override
    public ChallengeExtInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 2126222779:
          case 1508572736: {
            if (input.isAtField(FieldNames.bossInfo)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(bossInfo);
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum ChallengeExtInfoFactory implements MessageFactory<ChallengeExtInfo> {
      INSTANCE;

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

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