// Code generated by Wire protocol buffer compiler, do not edit.
// Source: squareup.protos.person.Person in person.proto
package com.squareup.wire.protos.person;

import android.os.Parcelable;
import com.squareup.wire.AndroidMessage;
import com.squareup.wire.Message;
import com.squareup.wire.ProtoAdapter;
import com.squareup.wire.Syntax;
import com.squareup.wire.WireEnum;
import com.squareup.wire.WireField;
import com.squareup.wire.internal.Internal;
import java.lang.Integer;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.List;
import okio.ByteString;

public final class Person extends AndroidMessage<Person, Person.Builder> {
  public static final ProtoAdapter<Person> ADAPTER = ProtoAdapter.newMessageAdapter(Person.class, "type.googleapis.com/squareup.protos.person.Person", Syntax.PROTO_2);

  public static final Parcelable.Creator<Person> CREATOR = AndroidMessage.newCreator(ADAPTER);

  private static final long serialVersionUID = 0L;

  public static final Integer DEFAULT_ID = 0;

  public static final String DEFAULT_NAME = "";

  public static final String DEFAULT_EMAIL = "";

  /**
   * The customer's ID number.
   */
  @WireField(
      tag = 2,
      adapter = "com.squareup.wire.ProtoAdapter#INT32",
      label = WireField.Label.REQUIRED
  )
  public final Integer id;

  /**
   * The customer's full name.
   */
  @WireField(
      tag = 1,
      adapter = "com.squareup.wire.ProtoAdapter#STRING",
      label = WireField.Label.REQUIRED
  )
  public final String name;

  /**
   * Email address for the customer.
   */
  @WireField(
      tag = 3,
      adapter = "com.squareup.wire.ProtoAdapter#STRING"
  )
  public final String email;

  /**
   * A list of the customer's phone numbers.
   */
  @WireField(
      tag = 4,
      adapter = "com.squareup.wire.protos.person.Person$PhoneNumber#ADAPTER",
      label = WireField.Label.REPEATED
  )
  public final List<PhoneNumber> phone;

  @WireField(
      tag = 5,
      adapter = "com.squareup.wire.ProtoAdapter#STRING",
      label = WireField.Label.REPEATED
  )
  public final List<String> aliases;

  public Person(Integer id, String name, String email, List<PhoneNumber> phone,
      List<String> aliases) {
    this(id, name, email, phone, aliases, ByteString.EMPTY);
  }

  public Person(Integer id, String name, String email, List<PhoneNumber> phone,
      List<String> aliases, ByteString unknownFields) {
    super(ADAPTER, unknownFields);
    this.id = id;
    this.name = name;
    this.email = email;
    this.phone = Internal.immutableCopyOf("phone", phone);
    this.aliases = Internal.immutableCopyOf("aliases", aliases);
  }

  @Override
  public Builder newBuilder() {
    Builder builder = new Builder();
    builder.id = id;
    builder.name = name;
    builder.email = email;
    builder.phone = Internal.copyOf(phone);
    builder.aliases = Internal.copyOf(aliases);
    builder.addUnknownFields(unknownFields());
    return builder;
  }

  @Override
  public boolean equals(Object other) {
    if (other == this) return true;
    if (!(other instanceof Person)) return false;
    Person o = (Person) other;
    return unknownFields().equals(o.unknownFields())
        && id.equals(o.id)
        && name.equals(o.name)
        && Internal.equals(email, o.email)
        && phone.equals(o.phone)
        && aliases.equals(o.aliases);
  }

  @Override
  public int hashCode() {
    int result = super.hashCode;
    if (result == 0) {
      result = unknownFields().hashCode();
      result = result * 37 + id.hashCode();
      result = result * 37 + name.hashCode();
      result = result * 37 + (email != null ? email.hashCode() : 0);
      result = result * 37 + phone.hashCode();
      result = result * 37 + aliases.hashCode();
      super.hashCode = result;
    }
    return result;
  }

  public static final class Builder extends Message.Builder<Person, Builder> {
    public Integer id;

    public String name;

    public String email;

    public List<PhoneNumber> phone;

    public List<String> aliases;

    public Builder() {
      phone = Internal.newMutableList();
      aliases = Internal.newMutableList();
    }

    /**
     * The customer's ID number.
     */
    public Builder id(Integer id) {
      this.id = id;
      return this;
    }

    /**
     * The customer's full name.
     */
    public Builder name(String name) {
      this.name = name;
      return this;
    }

    /**
     * Email address for the customer.
     */
    public Builder email(String email) {
      this.email = email;
      return this;
    }

    /**
     * A list of the customer's phone numbers.
     */
    public Builder phone(List<PhoneNumber> phone) {
      Internal.checkElementsNotNull(phone);
      this.phone = phone;
      return this;
    }

    public Builder aliases(List<String> aliases) {
      Internal.checkElementsNotNull(aliases);
      this.aliases = aliases;
      return this;
    }

    @Override
    public Person build() {
      if (id == null
          || name == null) {
        throw Internal.missingRequiredFields(id, "id",
            name, "name");
      }
      return new Person(id, name, email, phone, aliases, super.buildUnknownFields());
    }
  }

  public enum PhoneType implements WireEnum {
    MOBILE(0),

    HOME(1),

    /**
     * Could be phone or fax.
     */
    WORK(2);

    public static final ProtoAdapter<PhoneType> ADAPTER = ProtoAdapter.newEnumAdapter(PhoneType.class);

    private final int value;

    PhoneType(int value) {
      this.value = value;
    }

    /**
     * Return the constant for {@code value} or null.
     */
    public static PhoneType fromValue(int value) {
      switch (value) {
        case 0: return MOBILE;
        case 1: return HOME;
        case 2: return WORK;
        default: return null;
      }
    }

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

  public static final class PhoneNumber extends AndroidMessage<PhoneNumber, PhoneNumber.Builder> {
    public static final ProtoAdapter<PhoneNumber> ADAPTER = ProtoAdapter.newMessageAdapter(PhoneNumber.class, "type.googleapis.com/squareup.protos.person.Person.PhoneNumber", Syntax.PROTO_2);

    public static final Parcelable.Creator<PhoneNumber> CREATOR = AndroidMessage.newCreator(ADAPTER);

    private static final long serialVersionUID = 0L;

    public static final String DEFAULT_NUMBER = "";

    public static final PhoneType DEFAULT_TYPE = PhoneType.HOME;

    /**
     * The customer's phone number.
     */
    @WireField(
        tag = 1,
        adapter = "com.squareup.wire.ProtoAdapter#STRING",
        label = WireField.Label.REQUIRED
    )
    public final String number;

    /**
     * The type of phone stored here.
     */
    @WireField(
        tag = 2,
        adapter = "com.squareup.wire.protos.person.Person$PhoneType#ADAPTER"
    )
    public final PhoneType type;

    public PhoneNumber(String number, PhoneType type) {
      this(number, type, ByteString.EMPTY);
    }

    public PhoneNumber(String number, PhoneType type, ByteString unknownFields) {
      super(ADAPTER, unknownFields);
      this.number = number;
      this.type = type;
    }

    @Override
    public Builder newBuilder() {
      Builder builder = new Builder();
      builder.number = number;
      builder.type = type;
      builder.addUnknownFields(unknownFields());
      return builder;
    }

    @Override
    public boolean equals(Object other) {
      if (other == this) return true;
      if (!(other instanceof PhoneNumber)) return false;
      PhoneNumber o = (PhoneNumber) other;
      return unknownFields().equals(o.unknownFields())
          && number.equals(o.number)
          && Internal.equals(type, o.type);
    }

    @Override
    public int hashCode() {
      int result = super.hashCode;
      if (result == 0) {
        result = unknownFields().hashCode();
        result = result * 37 + number.hashCode();
        result = result * 37 + (type != null ? type.hashCode() : 0);
        super.hashCode = result;
      }
      return result;
    }

    public static final class Builder extends Message.Builder<PhoneNumber, Builder> {
      public String number;

      public PhoneType type;

      public Builder() {
      }

      /**
       * The customer's phone number.
       */
      public Builder number(String number) {
        this.number = number;
        return this;
      }

      /**
       * The type of phone stored here.
       */
      public Builder type(PhoneType type) {
        this.type = type;
        return this;
      }

      @Override
      public PhoneNumber build() {
        if (number == null) {
          throw Internal.missingRequiredFields(number, "number");
        }
        return new PhoneNumber(number, type, super.buildUnknownFields());
      }
    }
  }
}
