// Code generated by protocol buffer compiler. Do not edit!
package emu.nebula.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.ProtoEnum;
import us.hebi.quickbuf.ProtoMessage;
import us.hebi.quickbuf.ProtoSink;
import us.hebi.quickbuf.ProtoSource;
import us.hebi.quickbuf.ProtoUtil;
import us.hebi.quickbuf.RepeatedByte;

public final class DiscReadRewardReceive {
  /**
   * Protobuf enum {@code DiscReadType}
   */
  public enum DiscReadType implements ProtoEnum<DiscReadType> {
    /**
     * <code>UnknownType = 0;</code>
     */
    UnknownType("UnknownType", 0),

    /**
     * <code>DiscStory = 1;</code>
     */
    DiscStory("DiscStory", 1),

    /**
     * <code>DiscAVG = 2;</code>
     */
    DiscAVG("DiscAVG", 2);

    /**
     * <code>UnknownType = 0;</code>
     */
    public static final int UnknownType_VALUE = 0;

    /**
     * <code>DiscStory = 1;</code>
     */
    public static final int DiscStory_VALUE = 1;

    /**
     * <code>DiscAVG = 2;</code>
     */
    public static final int DiscAVG_VALUE = 2;

    private final String name;

    private final int number;

    private DiscReadType(String name, int number) {
      this.name = name;
      this.number = number;
    }

    /**
     * @return the string representation of enum entry
     */
    @Override
    public String getName() {
      return name;
    }

    /**
     * @return the numeric wire value of this enum entry
     */
    @Override
    public int getNumber() {
      return number;
    }

    /**
     * @return a converter that maps between this enum's numeric and text representations
     */
    public static ProtoEnum.EnumConverter<DiscReadType> converter() {
      return DiscReadTypeConverter.INSTANCE;
    }

    /**
     * @param value The numeric wire value of the corresponding enum entry.
     * @return The enum associated with the given numeric wire value, or null if unknown.
     */
    public static DiscReadType forNumber(int value) {
      return DiscReadTypeConverter.INSTANCE.forNumber(value);
    }

    /**
     * @param value The numeric wire value of the corresponding enum entry.
     * @param other Fallback value in case the value is not known.
     * @return The enum associated with the given numeric wire value, or the fallback value if unknown.
     */
    public static DiscReadType forNumberOr(int number, DiscReadType other) {
      DiscReadType value = forNumber(number);
      return value == null ? other : value;
    }

    enum DiscReadTypeConverter implements ProtoEnum.EnumConverter<DiscReadType> {
      INSTANCE;

      private static final DiscReadType[] lookup = new DiscReadType[3];

      static {
        lookup[0] = UnknownType;
        lookup[1] = DiscStory;
        lookup[2] = DiscAVG;
      }

      @Override
      public final DiscReadType forNumber(final int value) {
        if (value >= 0 && value < lookup.length) {
          return lookup[value];
        }
        return null;
      }

      @Override
      public final DiscReadType forName(final CharSequence value) {
        if (value.length() == 7) {
          if (ProtoUtil.isEqual("DiscAVG", value)) {
            return DiscAVG;
          }
        }
        if (value.length() == 9) {
          if (ProtoUtil.isEqual("DiscStory", value)) {
            return DiscStory;
          }
        }
        if (value.length() == 11) {
          if (ProtoUtil.isEqual("UnknownType", value)) {
            return UnknownType;
          }
        }
        return null;
      }
    }
  }

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

    /**
     * <code>optional uint32 Id = 1;</code>
     */
    private int id;

    /**
     * <code>optional .DiscReadType ReadType = 2;</code>
     */
    private int readType;

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     */
    private final RepeatedByte nextPackage = RepeatedByte.newEmptyInstance();

    private DiscReadRewardReceiveReq() {
    }

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

    /**
     * <code>optional uint32 Id = 1;</code>
     * @return whether the id field is set
     */
    public boolean hasId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 Id = 1;</code>
     * @return this
     */
    public DiscReadRewardReceiveReq clearId() {
      bitField0_ &= ~0x00000001;
      id = 0;
      return this;
    }

    /**
     * <code>optional uint32 Id = 1;</code>
     * @return the id
     */
    public int getId() {
      return id;
    }

    /**
     * <code>optional uint32 Id = 1;</code>
     * @param value the id to set
     * @return this
     */
    public DiscReadRewardReceiveReq setId(final int value) {
      bitField0_ |= 0x00000001;
      id = value;
      return this;
    }

    /**
     * <code>optional .DiscReadType ReadType = 2;</code>
     * @return whether the readType field is set
     */
    public boolean hasReadType() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional .DiscReadType ReadType = 2;</code>
     * @return this
     */
    public DiscReadRewardReceiveReq clearReadType() {
      bitField0_ &= ~0x00000002;
      readType = 0;
      return this;
    }

    /**
     * <code>optional .DiscReadType ReadType = 2;</code>
     * @return the readType
     */
    public DiscReadType getReadType() {
      return DiscReadType.forNumber(readType);
    }

    /**
     * Gets the value of the internal enum store. The result is
     * equivalent to {@link DiscReadRewardReceiveReq#getReadType()}.getNumber().
     *
     * @return numeric wire representation
     */
    public int getReadTypeValue() {
      return readType;
    }

    /**
     * Sets the value of the internal enum store. This does not
     * do any validity checks, so be sure to use appropriate value
     * constants from {@link DiscReadType}. Setting an invalid value
     * can cause {@link DiscReadRewardReceiveReq#getReadType()} to return null
     *
     * @param value the numeric wire value to set
     * @return this
     */
    public DiscReadRewardReceiveReq setReadTypeValue(final int value) {
      bitField0_ |= 0x00000002;
      readType = value;
      return this;
    }

    /**
     * <code>optional .DiscReadType ReadType = 2;</code>
     * @param value the readType to set
     * @return this
     */
    public DiscReadRewardReceiveReq setReadType(final DiscReadType value) {
      bitField0_ |= 0x00000002;
      readType = value.getNumber();
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return whether the nextPackage field is set
     */
    public boolean hasNextPackage() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return this
     */
    public DiscReadRewardReceiveReq clearNextPackage() {
      bitField0_ &= ~0x00000004;
      nextPackage.clear();
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</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 #getMutableNextPackage()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedByte getNextPackage() {
      return nextPackage;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</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 RepeatedByte getMutableNextPackage() {
      bitField0_ |= 0x00000004;
      return nextPackage;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param value the nextPackage to add
     * @return this
     */
    public DiscReadRewardReceiveReq addNextPackage(final byte value) {
      bitField0_ |= 0x00000004;
      nextPackage.add(value);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param values the nextPackage to add
     * @return this
     */
    public DiscReadRewardReceiveReq addAllNextPackage(final byte... values) {
      bitField0_ |= 0x00000004;
      nextPackage.addAll(values);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param values the nextPackage to set
     * @return this
     */
    public DiscReadRewardReceiveReq setNextPackage(final byte... values) {
      bitField0_ |= 0x00000004;
      nextPackage.copyFrom(values);
      return this;
    }

    @Override
    public DiscReadRewardReceiveReq copyFrom(final DiscReadRewardReceiveReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        id = other.id;
        readType = other.readType;
        nextPackage.copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public DiscReadRewardReceiveReq mergeFrom(final DiscReadRewardReceiveReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasId()) {
        setId(other.id);
      }
      if (other.hasReadType()) {
        setReadTypeValue(other.readType);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public DiscReadRewardReceiveReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      id = 0;
      readType = 0;
      nextPackage.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof DiscReadRewardReceiveReq)) {
        return false;
      }
      DiscReadRewardReceiveReq other = (DiscReadRewardReceiveReq) o;
      return bitField0_ == other.bitField0_
        && (!hasId() || id == other.id)
        && (!hasReadType() || readType == other.readType)
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 8);
        output.writeUInt32NoTag(id);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 16);
        output.writeEnumNoTag(readType);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(id);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeEnumSizeNoTag(readType);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public DiscReadRewardReceiveReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 8: {
            // id
            id = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 16) {
              break;
            }
          }
          case 16: {
            // readType
            final int value = input.readInt32();
            if (DiscReadType.forNumber(value) != null) {
              readType = value;
              bitField0_ |= 0x00000002;
            }
            tag = input.readTag();
            if (tag != 16378) {
              break;
            }
          }
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            bitField0_ |= 0x00000004;
            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.id, id);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeEnum(FieldNames.readType, readType, DiscReadType.converter());
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      output.endObject();
    }

    @Override
    public DiscReadRewardReceiveReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 2363: {
            if (input.isAtField(FieldNames.id)) {
              if (!input.trySkipNullValue()) {
                id = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -802879984: {
            if (input.isAtField(FieldNames.readType)) {
              if (!input.trySkipNullValue()) {
                final DiscReadType value = input.readEnum(DiscReadType.converter());
                if (value != null) {
                  readType = value.getNumber();
                  bitField0_ |= 0x00000002;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum DiscReadRewardReceiveReqFactory implements MessageFactory<DiscReadRewardReceiveReq> {
      INSTANCE;

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

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

      static final FieldName readType = FieldName.forField("ReadType");

      static final FieldName nextPackage = FieldName.forField("NextPackage");
    }
  }
}
