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

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

    private ChallengeDevelopmentInfo() {
    }

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

    /**
     * <code>optional uint32 challenge_id = 14;</code>
     * @return whether the challengeId field is set
     */
    public boolean hasChallengeId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 challenge_id = 14;</code>
     * @return this
     */
    public ChallengeDevelopmentInfo clearChallengeId() {
      bitField0_ &= ~0x00000001;
      challengeId = 0;
      return this;
    }

    /**
     * <code>optional uint32 challenge_id = 14;</code>
     * @return the challengeId
     */
    public int getChallengeId() {
      return challengeId;
    }

    /**
     * <code>optional uint32 challenge_id = 14;</code>
     * @param value the challengeId to set
     * @return this
     */
    public ChallengeDevelopmentInfo setChallengeId(final int value) {
      bitField0_ |= 0x00000001;
      challengeId = value;
      return this;
    }

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

    @Override
    public ChallengeDevelopmentInfo mergeFrom(final ChallengeDevelopmentInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasChallengeId()) {
        setChallengeId(other.challengeId);
      }
      return this;
    }

    @Override
    public ChallengeDevelopmentInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      challengeId = 0;
      return this;
    }

    @Override
    public ChallengeDevelopmentInfo 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 ChallengeDevelopmentInfo)) {
        return false;
      }
      ChallengeDevelopmentInfo other = (ChallengeDevelopmentInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasChallengeId() || challengeId == other.challengeId);
    }

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

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

    @Override
    @SuppressWarnings("fallthrough")
    public ChallengeDevelopmentInfo mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 112: {
            // challengeId
            challengeId = input.readUInt32();
            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.writeUInt32(FieldNames.challengeId, challengeId);
      }
      output.endObject();
    }

    @Override
    public ChallengeDevelopmentInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -689112866:
          case 112359031: {
            if (input.isAtField(FieldNames.challengeId)) {
              if (!input.trySkipNullValue()) {
                challengeId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum ChallengeDevelopmentInfoFactory implements MessageFactory<ChallengeDevelopmentInfo> {
      INSTANCE;

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

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