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

    /**
     * <pre>
     *  HEDLHGFPCGG
     * </pre>
     *
     * <code>optional uint32 group_id = 5;</code>
     */
    private int groupId;

    /**
     * <pre>
     *  ECFFNHDIMPP
     * </pre>
     *
     * <code>optional .SwitchHandOpPropType op_type = 6;</code>
     */
    private int opType;

    private SwitchHandOpData() {
    }

    /**
     * <pre>
     *  CNIADJCLKKF
     * </pre>
     *
     * @return a new empty instance of {@code SwitchHandOpData}
     */
    public static SwitchHandOpData newInstance() {
      return new SwitchHandOpData();
    }

    /**
     * <pre>
     *  HEDLHGFPCGG
     * </pre>
     *
     * <code>optional uint32 group_id = 5;</code>
     * @return whether the groupId field is set
     */
    public boolean hasGroupId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <pre>
     *  HEDLHGFPCGG
     * </pre>
     *
     * <code>optional uint32 group_id = 5;</code>
     * @return this
     */
    public SwitchHandOpData clearGroupId() {
      bitField0_ &= ~0x00000001;
      groupId = 0;
      return this;
    }

    /**
     * <pre>
     *  HEDLHGFPCGG
     * </pre>
     *
     * <code>optional uint32 group_id = 5;</code>
     * @return the groupId
     */
    public int getGroupId() {
      return groupId;
    }

    /**
     * <pre>
     *  HEDLHGFPCGG
     * </pre>
     *
     * <code>optional uint32 group_id = 5;</code>
     * @param value the groupId to set
     * @return this
     */
    public SwitchHandOpData setGroupId(final int value) {
      bitField0_ |= 0x00000001;
      groupId = value;
      return this;
    }

    /**
     * <pre>
     *  ECFFNHDIMPP
     * </pre>
     *
     * <code>optional .SwitchHandOpPropType op_type = 6;</code>
     * @return whether the opType field is set
     */
    public boolean hasOpType() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <pre>
     *  ECFFNHDIMPP
     * </pre>
     *
     * <code>optional .SwitchHandOpPropType op_type = 6;</code>
     * @return this
     */
    public SwitchHandOpData clearOpType() {
      bitField0_ &= ~0x00000002;
      opType = 0;
      return this;
    }

    /**
     * <pre>
     *  ECFFNHDIMPP
     * </pre>
     *
     * <code>optional .SwitchHandOpPropType op_type = 6;</code>
     * @return the opType
     */
    public SwitchHandOpPropTypeOuterClass.SwitchHandOpPropType getOpType() {
      return SwitchHandOpPropTypeOuterClass.SwitchHandOpPropType.forNumber(opType);
    }

    /**
     * Gets the value of the internal enum store. The result is
     * equivalent to {@link SwitchHandOpData#getOpType()}.getNumber().
     *
     * @return numeric wire representation
     */
    public int getOpTypeValue() {
      return opType;
    }

    /**
     * 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 SwitchHandOpPropTypeOuterClass.SwitchHandOpPropType}. Setting an invalid value
     * can cause {@link SwitchHandOpData#getOpType()} to return null
     *
     * @param value the numeric wire value to set
     * @return this
     */
    public SwitchHandOpData setOpTypeValue(final int value) {
      bitField0_ |= 0x00000002;
      opType = value;
      return this;
    }

    /**
     * <pre>
     *  ECFFNHDIMPP
     * </pre>
     *
     * <code>optional .SwitchHandOpPropType op_type = 6;</code>
     * @param value the opType to set
     * @return this
     */
    public SwitchHandOpData setOpType(
        final SwitchHandOpPropTypeOuterClass.SwitchHandOpPropType value) {
      bitField0_ |= 0x00000002;
      opType = value.getNumber();
      return this;
    }

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

    @Override
    public SwitchHandOpData mergeFrom(final SwitchHandOpData other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasGroupId()) {
        setGroupId(other.groupId);
      }
      if (other.hasOpType()) {
        setOpTypeValue(other.opType);
      }
      return this;
    }

    @Override
    public SwitchHandOpData clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      groupId = 0;
      opType = 0;
      return this;
    }

    @Override
    public SwitchHandOpData 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 SwitchHandOpData)) {
        return false;
      }
      SwitchHandOpData other = (SwitchHandOpData) o;
      return bitField0_ == other.bitField0_
        && (!hasGroupId() || groupId == other.groupId)
        && (!hasOpType() || opType == other.opType);
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 40);
        output.writeUInt32NoTag(groupId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 48);
        output.writeEnumNoTag(opType);
      }
    }

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

    @Override
    @SuppressWarnings("fallthrough")
    public SwitchHandOpData mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 40: {
            // groupId
            groupId = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 48) {
              break;
            }
          }
          case 48: {
            // opType
            final int value = input.readInt32();
            if (SwitchHandOpPropTypeOuterClass.SwitchHandOpPropType.forNumber(value) != null) {
              opType = value;
              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.groupId, groupId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeEnum(FieldNames.opType, opType, SwitchHandOpPropTypeOuterClass.SwitchHandOpPropType.converter());
      }
      output.endObject();
    }

    @Override
    public SwitchHandOpData mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 293428218:
          case 506361563: {
            if (input.isAtField(FieldNames.groupId)) {
              if (!input.trySkipNullValue()) {
                groupId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1011074885:
          case -1268531496: {
            if (input.isAtField(FieldNames.opType)) {
              if (!input.trySkipNullValue()) {
                final SwitchHandOpPropTypeOuterClass.SwitchHandOpPropType value = input.readEnum(SwitchHandOpPropTypeOuterClass.SwitchHandOpPropType.converter());
                if (value != null) {
                  opType = value.getNumber();
                  bitField0_ |= 0x00000002;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum SwitchHandOpDataFactory implements MessageFactory<SwitchHandOpData> {
      INSTANCE;

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

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

      static final FieldName opType = FieldName.forField("opType", "op_type");
    }
  }
}
