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

    /**
     * <code>optional uint32 head_icon_frame_id = 9;</code>
     */
    private int headIconFrameId;

    private HeadIconFrameInfo() {
    }

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

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

    /**
     * <code>optional uint32 head_icon_frame_id = 9;</code>
     * @return this
     */
    public HeadIconFrameInfo clearHeadIconFrameId() {
      bitField0_ &= ~0x00000001;
      headIconFrameId = 0;
      return this;
    }

    /**
     * <code>optional uint32 head_icon_frame_id = 9;</code>
     * @return the headIconFrameId
     */
    public int getHeadIconFrameId() {
      return headIconFrameId;
    }

    /**
     * <code>optional uint32 head_icon_frame_id = 9;</code>
     * @param value the headIconFrameId to set
     * @return this
     */
    public HeadIconFrameInfo setHeadIconFrameId(final int value) {
      bitField0_ |= 0x00000001;
      headIconFrameId = value;
      return this;
    }

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

    @Override
    public HeadIconFrameInfo mergeFrom(final HeadIconFrameInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasHeadIconFrameId()) {
        setHeadIconFrameId(other.headIconFrameId);
      }
      return this;
    }

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

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

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

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

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

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

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

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

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

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

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

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

    private enum HeadIconFrameInfoFactory implements MessageFactory<HeadIconFrameInfo> {
      INSTANCE;

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

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