// 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.ProtoMessage;
import us.hebi.quickbuf.ProtoSink;
import us.hebi.quickbuf.ProtoSource;
import us.hebi.quickbuf.RepeatedByte;

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

    /**
     * <code>optional uint32 ActivityId = 1;</code>
     */
    private int activityId;

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

    private ActivityMiningApplyReq() {
    }

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

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

    /**
     * <code>optional uint32 ActivityId = 1;</code>
     * @return this
     */
    public ActivityMiningApplyReq clearActivityId() {
      bitField0_ &= ~0x00000001;
      activityId = 0;
      return this;
    }

    /**
     * <code>optional uint32 ActivityId = 1;</code>
     * @return the activityId
     */
    public int getActivityId() {
      return activityId;
    }

    /**
     * <code>optional uint32 ActivityId = 1;</code>
     * @param value the activityId to set
     * @return this
     */
    public ActivityMiningApplyReq setActivityId(final int value) {
      bitField0_ |= 0x00000001;
      activityId = value;
      return this;
    }

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

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return this
     */
    public ActivityMiningApplyReq clearNextPackage() {
      bitField0_ &= ~0x00000002;
      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_ |= 0x00000002;
      return nextPackage;
    }

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

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

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

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

    @Override
    public ActivityMiningApplyReq mergeFrom(final ActivityMiningApplyReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasActivityId()) {
        setActivityId(other.activityId);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      return this;
    }

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

    @Override
    public ActivityMiningApplyReq 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 ActivityMiningApplyReq)) {
        return false;
      }
      ActivityMiningApplyReq other = (ActivityMiningApplyReq) o;
      return bitField0_ == other.bitField0_
        && (!hasActivityId() || activityId == other.activityId)
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage));
    }

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

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

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

    @Override
    public ActivityMiningApplyReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -252882774: {
            if (input.isAtField(FieldNames.activityId)) {
              if (!input.trySkipNullValue()) {
                activityId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum ActivityMiningApplyReqFactory implements MessageFactory<ActivityMiningApplyReq> {
      INSTANCE;

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

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

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

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

    /**
     * <code>optional .MiningLayer Layer = 1;</code>
     */
    private final PublicMining.MiningLayer layer = PublicMining.MiningLayer.newInstance();

    /**
     * <code>optional .MiningChangeInfo MiningChangeInfo = 2;</code>
     */
    private final PublicMining.MiningChangeInfo miningChangeInfo = PublicMining.MiningChangeInfo.newInstance();

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

    private ActivityMiningApplyResp() {
    }

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

    /**
     * <code>optional .MiningLayer Layer = 1;</code>
     * @return whether the layer field is set
     */
    public boolean hasLayer() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional .MiningLayer Layer = 1;</code>
     * @return this
     */
    public ActivityMiningApplyResp clearLayer() {
      bitField0_ &= ~0x00000001;
      layer.clear();
      return this;
    }

    /**
     * <code>optional .MiningLayer Layer = 1;</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 #getMutableLayer()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public PublicMining.MiningLayer getLayer() {
      return layer;
    }

    /**
     * <code>optional .MiningLayer Layer = 1;</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 PublicMining.MiningLayer getMutableLayer() {
      bitField0_ |= 0x00000001;
      return layer;
    }

    /**
     * <code>optional .MiningLayer Layer = 1;</code>
     * @param value the layer to set
     * @return this
     */
    public ActivityMiningApplyResp setLayer(final PublicMining.MiningLayer value) {
      bitField0_ |= 0x00000001;
      layer.copyFrom(value);
      return this;
    }

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

    /**
     * <code>optional .MiningChangeInfo MiningChangeInfo = 2;</code>
     * @return this
     */
    public ActivityMiningApplyResp clearMiningChangeInfo() {
      bitField0_ &= ~0x00000002;
      miningChangeInfo.clear();
      return this;
    }

    /**
     * <code>optional .MiningChangeInfo MiningChangeInfo = 2;</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 #getMutableMiningChangeInfo()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public PublicMining.MiningChangeInfo getMiningChangeInfo() {
      return miningChangeInfo;
    }

    /**
     * <code>optional .MiningChangeInfo MiningChangeInfo = 2;</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 PublicMining.MiningChangeInfo getMutableMiningChangeInfo() {
      bitField0_ |= 0x00000002;
      return miningChangeInfo;
    }

    /**
     * <code>optional .MiningChangeInfo MiningChangeInfo = 2;</code>
     * @param value the miningChangeInfo to set
     * @return this
     */
    public ActivityMiningApplyResp setMiningChangeInfo(final PublicMining.MiningChangeInfo value) {
      bitField0_ |= 0x00000002;
      miningChangeInfo.copyFrom(value);
      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 ActivityMiningApplyResp 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 ActivityMiningApplyResp 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 ActivityMiningApplyResp 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 ActivityMiningApplyResp setNextPackage(final byte... values) {
      bitField0_ |= 0x00000004;
      nextPackage.copyFrom(values);
      return this;
    }

    @Override
    public ActivityMiningApplyResp copyFrom(final ActivityMiningApplyResp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        layer.copyFrom(other.layer);
        miningChangeInfo.copyFrom(other.miningChangeInfo);
        nextPackage.copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public ActivityMiningApplyResp mergeFrom(final ActivityMiningApplyResp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasLayer()) {
        getMutableLayer().mergeFrom(other.layer);
      }
      if (other.hasMiningChangeInfo()) {
        getMutableMiningChangeInfo().mergeFrom(other.miningChangeInfo);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      return this;
    }

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ActivityMiningApplyResp)) {
        return false;
      }
      ActivityMiningApplyResp other = (ActivityMiningApplyResp) o;
      return bitField0_ == other.bitField0_
        && (!hasLayer() || layer.equals(other.layer))
        && (!hasMiningChangeInfo() || miningChangeInfo.equals(other.miningChangeInfo))
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 10);
        output.writeMessageNoTag(layer);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 18);
        output.writeMessageNoTag(miningChangeInfo);
      }
      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.computeMessageSizeNoTag(layer);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(miningChangeInfo);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ActivityMiningApplyResp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 10: {
            // layer
            input.readMessage(layer);
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 18) {
              break;
            }
          }
          case 18: {
            // miningChangeInfo
            input.readMessage(miningChangeInfo);
            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.writeMessage(FieldNames.layer, layer);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeMessage(FieldNames.miningChangeInfo, miningChangeInfo);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      output.endObject();
    }

    @Override
    public ActivityMiningApplyResp mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 73196849: {
            if (input.isAtField(FieldNames.layer)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(layer);
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1023670002: {
            if (input.isAtField(FieldNames.miningChangeInfo)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(miningChangeInfo);
                bitField0_ |= 0x00000002;
              }
            } 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 ActivityMiningApplyResp clone() {
      return new ActivityMiningApplyResp().copyFrom(this);
    }

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

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

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

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

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

    private enum ActivityMiningApplyRespFactory implements MessageFactory<ActivityMiningApplyResp> {
      INSTANCE;

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

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

      static final FieldName miningChangeInfo = FieldName.forField("MiningChangeInfo");

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