// 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.ProtoField;
import java.util.Collections;
import java.util.List;

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.REPEATED;
import static com.squareup.wire.Message.Label.REQUIRED;

/**
 * TAG: 3
 */
public final class LoginResponse extends Message {

  public static final String DEFAULT_ID = "";
  public static final String DEFAULT_JID = "";
  public static final List<Setting> DEFAULT_SETTING = Collections.emptyList();
  public static final Integer DEFAULT_STREAM_ID = 0;
  public static final Integer DEFAULT_LAST_STREAM_ID_RECEIVED = 0;
  public static final Long DEFAULT_SERVER_TIMESTAMP = 0L;

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

  /**
   * Not used.
   */
  @ProtoField(tag = 2, type = STRING)
  public final String jid;

  /**
   * Null if login was ok.
   */
  @ProtoField(tag = 3)
  public final ErrorInfo error;

  @ProtoField(tag = 4, label = REPEATED, messageType = Setting.class)
  public final List<Setting> setting;

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

  /**
   * Should be "1"
   */
  @ProtoField(tag = 6, type = INT32)
  public final Integer last_stream_id_received;

  @ProtoField(tag = 7)
  public final HeartbeatConfig heartbeat_config;

  /**
   * used by the client to synchronize with the server timestamp.
   */
  @ProtoField(tag = 8, type = INT64)
  public final Long server_timestamp;

  public LoginResponse(String id, String jid, ErrorInfo error, List<Setting> setting, Integer stream_id, Integer last_stream_id_received, HeartbeatConfig heartbeat_config, Long server_timestamp) {
    this.id = id;
    this.jid = jid;
    this.error = error;
    this.setting = immutableCopyOf(setting);
    this.stream_id = stream_id;
    this.last_stream_id_received = last_stream_id_received;
    this.heartbeat_config = heartbeat_config;
    this.server_timestamp = server_timestamp;
  }

  private LoginResponse(Builder builder) {
    this(builder.id, builder.jid, builder.error, builder.setting, builder.stream_id, builder.last_stream_id_received, builder.heartbeat_config, builder.server_timestamp);
    setBuilder(builder);
  }

  @Override
  public boolean equals(Object other) {
    if (other == this) return true;
    if (!(other instanceof LoginResponse)) return false;
    LoginResponse o = (LoginResponse) other;
    return equals(id, o.id)
        && equals(jid, o.jid)
        && equals(error, o.error)
        && equals(setting, o.setting)
        && equals(stream_id, o.stream_id)
        && equals(last_stream_id_received, o.last_stream_id_received)
        && equals(heartbeat_config, o.heartbeat_config)
        && equals(server_timestamp, o.server_timestamp);
  }

  @Override
  public int hashCode() {
    int result = hashCode;
    if (result == 0) {
      result = id != null ? id.hashCode() : 0;
      result = result * 37 + (jid != null ? jid.hashCode() : 0);
      result = result * 37 + (error != null ? error.hashCode() : 0);
      result = result * 37 + (setting != null ? setting.hashCode() : 1);
      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 + (heartbeat_config != null ? heartbeat_config.hashCode() : 0);
      result = result * 37 + (server_timestamp != null ? server_timestamp.hashCode() : 0);
      hashCode = result;
    }
    return result;
  }

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

    public String id;
    public String jid;
    public ErrorInfo error;
    public List<Setting> setting;
    public Integer stream_id;
    public Integer last_stream_id_received;
    public HeartbeatConfig heartbeat_config;
    public Long server_timestamp;

    public Builder() {
    }

    public Builder(LoginResponse message) {
      super(message);
      if (message == null) return;
      this.id = message.id;
      this.jid = message.jid;
      this.error = message.error;
      this.setting = copyOf(message.setting);
      this.stream_id = message.stream_id;
      this.last_stream_id_received = message.last_stream_id_received;
      this.heartbeat_config = message.heartbeat_config;
      this.server_timestamp = message.server_timestamp;
    }

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

    /**
     * Not used.
     */
    public Builder jid(String jid) {
      this.jid = jid;
      return this;
    }

    /**
     * Null if login was ok.
     */
    public Builder error(ErrorInfo error) {
      this.error = error;
      return this;
    }

    public Builder setting(List<Setting> setting) {
      this.setting = checkForNulls(setting);
      return this;
    }

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

    /**
     * Should be "1"
     */
    public Builder last_stream_id_received(Integer last_stream_id_received) {
      this.last_stream_id_received = last_stream_id_received;
      return this;
    }

    public Builder heartbeat_config(HeartbeatConfig heartbeat_config) {
      this.heartbeat_config = heartbeat_config;
      return this;
    }

    /**
     * used by the client to synchronize with the server timestamp.
     */
    public Builder server_timestamp(Long server_timestamp) {
      this.server_timestamp = server_timestamp;
      return this;
    }

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