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

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

    private GetFriendChallengeLineupCsReq() {
    }

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

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

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

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

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

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

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

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

    @Override
    public GetFriendChallengeLineupCsReq 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 GetFriendChallengeLineupCsReq)) {
        return false;
      }
      GetFriendChallengeLineupCsReq other = (GetFriendChallengeLineupCsReq) 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) 72);
        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 GetFriendChallengeLineupCsReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 72: {
            // 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 GetFriendChallengeLineupCsReq 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 GetFriendChallengeLineupCsReq clone() {
      return new GetFriendChallengeLineupCsReq().copyFrom(this);
    }

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

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

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

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

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

    private enum GetFriendChallengeLineupCsReqFactory implements MessageFactory<GetFriendChallengeLineupCsReq> {
      INSTANCE;

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

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