// Code generated by Wire protocol buffer compiler, do not edit.
// Source file: protos-repo/mcs.proto
package org.microg.gms.gcm.mcs;

import com.squareup.wire.Message;
import com.squareup.wire.ProtoEnum;
import com.squareup.wire.ProtoField;

import static com.squareup.wire.Message.Datatype.ENUM;
import static com.squareup.wire.Message.Datatype.INT32;
import static com.squareup.wire.Message.Datatype.INT64;
import static com.squareup.wire.Message.Datatype.STRING;
import static com.squareup.wire.Message.Label.REQUIRED;

/**
 * TAG: 7
 * IqRequest must contain a single extension.  IqResponse may contain 0 or 1
 * extensions.
 */
public final class IqStanza extends Message {

  public static final Long DEFAULT_RMQ_ID = 0L;
  public static final IqType DEFAULT_TYPE = IqType.GET;
  public static final String DEFAULT_ID = "";
  public static final String DEFAULT_FROM = "";
  public static final String DEFAULT_TO = "";
  public static final String DEFAULT_PERSISTENT_ID = "";
  public static final Integer DEFAULT_STREAM_ID = 0;
  public static final Integer DEFAULT_LAST_STREAM_ID_RECEIVED = 0;
  public static final Long DEFAULT_ACCOUNT_ID = 0L;
  public static final Long DEFAULT_STATUS = 0L;

  @ProtoField(tag = 1, type = INT64)
  public final Long rmq_id;

  @ProtoField(tag = 2, type = ENUM, label = REQUIRED)
  public final IqType type;

  @ProtoField(tag = 3, type = STRING, label = REQUIRED)
  public final String id;

  @ProtoField(tag = 4, type = STRING)
  public final String from;

  @ProtoField(tag = 5, type = STRING)
  public final String to;

  @ProtoField(tag = 6)
  public final ErrorInfo error;

  /**
   * Only field used in the 38+ protocol (besides common last_stream_id_received, status, rmq_id)
   */
  @ProtoField(tag = 7)
  public final Extension extension;

  @ProtoField(tag = 8, type = STRING)
  public final String persistent_id;

  @ProtoField(tag = 9, type = INT32)
  public final Integer stream_id;

  @ProtoField(tag = 10, type = INT32)
  public final Integer last_stream_id_received;

  @ProtoField(tag = 11, type = INT64)
  public final Long account_id;

  @ProtoField(tag = 12, type = INT64)
  public final Long status;

  public IqStanza(Long rmq_id, IqType type, String id, String from, String to, ErrorInfo error, Extension extension, String persistent_id, Integer stream_id, Integer last_stream_id_received, Long account_id, Long status) {
    this.rmq_id = rmq_id;
    this.type = type;
    this.id = id;
    this.from = from;
    this.to = to;
    this.error = error;
    this.extension = extension;
    this.persistent_id = persistent_id;
    this.stream_id = stream_id;
    this.last_stream_id_received = last_stream_id_received;
    this.account_id = account_id;
    this.status = status;
  }

  private IqStanza(Builder builder) {
    this(builder.rmq_id, builder.type, builder.id, builder.from, builder.to, builder.error, builder.extension, builder.persistent_id, builder.stream_id, builder.last_stream_id_received, builder.account_id, builder.status);
    setBuilder(builder);
  }

  @Override
  public boolean equals(Object other) {
    if (other == this) return true;
    if (!(other instanceof IqStanza)) return false;
    IqStanza o = (IqStanza) other;
    return equals(rmq_id, o.rmq_id)
        && equals(type, o.type)
        && equals(id, o.id)
        && equals(from, o.from)
        && equals(to, o.to)
        && equals(error, o.error)
        && equals(extension, o.extension)
        && equals(persistent_id, o.persistent_id)
        && equals(stream_id, o.stream_id)
        && equals(last_stream_id_received, o.last_stream_id_received)
        && equals(account_id, o.account_id)
        && equals(status, o.status);
  }

  @Override
  public int hashCode() {
    int result = hashCode;
    if (result == 0) {
      result = rmq_id != null ? rmq_id.hashCode() : 0;
      result = result * 37 + (type != null ? type.hashCode() : 0);
      result = result * 37 + (id != null ? id.hashCode() : 0);
      result = result * 37 + (from != null ? from.hashCode() : 0);
      result = result * 37 + (to != null ? to.hashCode() : 0);
      result = result * 37 + (error != null ? error.hashCode() : 0);
      result = result * 37 + (extension != null ? extension.hashCode() : 0);
      result = result * 37 + (persistent_id != null ? persistent_id.hashCode() : 0);
      result = result * 37 + (stream_id != null ? stream_id.hashCode() : 0);
      result = result * 37 + (last_stream_id_received != null ? last_stream_id_received.hashCode() : 0);
      result = result * 37 + (account_id != null ? account_id.hashCode() : 0);
      result = result * 37 + (status != null ? status.hashCode() : 0);
      hashCode = result;
    }
    return result;
  }

  public static final class Builder extends Message.Builder<IqStanza> {

    public Long rmq_id;
    public IqType type;
    public String id;
    public String from;
    public String to;
    public ErrorInfo error;
    public Extension extension;
    public String persistent_id;
    public Integer stream_id;
    public Integer last_stream_id_received;
    public Long account_id;
    public Long status;

    public Builder() {
    }

    public Builder(IqStanza message) {
      super(message);
      if (message == null) return;
      this.rmq_id = message.rmq_id;
      this.type = message.type;
      this.id = message.id;
      this.from = message.from;
      this.to = message.to;
      this.error = message.error;
      this.extension = message.extension;
      this.persistent_id = message.persistent_id;
      this.stream_id = message.stream_id;
      this.last_stream_id_received = message.last_stream_id_received;
      this.account_id = message.account_id;
      this.status = message.status;
    }

    public Builder rmq_id(Long rmq_id) {
      this.rmq_id = rmq_id;
      return this;
    }

    public Builder type(IqType type) {
      this.type = type;
      return this;
    }

    public Builder id(String id) {
      this.id = id;
      return this;
    }

    public Builder from(String from) {
      this.from = from;
      return this;
    }

    public Builder to(String to) {
      this.to = to;
      return this;
    }

    public Builder error(ErrorInfo error) {
      this.error = error;
      return this;
    }

    /**
     * Only field used in the 38+ protocol (besides common last_stream_id_received, status, rmq_id)
     */
    public Builder extension(Extension extension) {
      this.extension = extension;
      return this;
    }

    public Builder persistent_id(String persistent_id) {
      this.persistent_id = persistent_id;
      return this;
    }

    public Builder stream_id(Integer stream_id) {
      this.stream_id = stream_id;
      return this;
    }

    public Builder last_stream_id_received(Integer last_stream_id_received) {
      this.last_stream_id_received = last_stream_id_received;
      return this;
    }

    public Builder account_id(Long account_id) {
      this.account_id = account_id;
      return this;
    }

    public Builder status(Long status) {
      this.status = status;
      return this;
    }

    @Override
    public IqStanza build() {
      checkRequiredFields();
      return new IqStanza(this);
    }
  }

  public enum IqType
      implements ProtoEnum {
    GET(0),
    SET(1),
    RESULT(2),
    IQ_ERROR(3);

    private final int value;

    private IqType(int value) {
      this.value = value;
    }

    @Override
    public int getValue() {
      return value;
    }
  }
}
