// Code generated by Wire protocol buffer compiler, do not edit.
// Source: squareup.proto3.PizzaDelivery in pizza.proto
package squareup.proto3;

import com.squareup.wire.AnyMessage;
import com.squareup.wire.Message;
import com.squareup.wire.ProtoAdapter;
import com.squareup.wire.Syntax;
import com.squareup.wire.WireField;
import com.squareup.wire.internal.Internal;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import okio.ByteString;

public final class PizzaDelivery extends Message<PizzaDelivery, PizzaDelivery.Builder> {
  public static final ProtoAdapter<PizzaDelivery> ADAPTER = ProtoAdapter.newMessageAdapter(PizzaDelivery.class, "type.googleapis.com/squareup.proto3.PizzaDelivery", Syntax.PROTO_3);

  private static final long serialVersionUID = 0L;

  @WireField(
      tag = 1,
      adapter = "com.squareup.wire.ProtoAdapter#STRING",
      label = WireField.Label.OMIT_IDENTITY,
      jsonName = "phoneNumber"
  )
  public final String phone_number;

  @WireField(
      tag = 2,
      adapter = "com.squareup.wire.ProtoAdapter#STRING",
      label = WireField.Label.OMIT_IDENTITY
  )
  public final String address;

  @WireField(
      tag = 3,
      adapter = "squareup.proto3.Pizza#ADAPTER",
      label = WireField.Label.REPEATED
  )
  public final List<Pizza> pizzas;

  @WireField(
      tag = 4,
      adapter = "com.squareup.wire.AnyMessage#ADAPTER",
      label = WireField.Label.OMIT_IDENTITY
  )
  public final AnyMessage promotion;

  @WireField(
      tag = 5,
      adapter = "com.squareup.wire.ProtoAdapter#DURATION",
      label = WireField.Label.OMIT_IDENTITY,
      jsonName = "deliveredWithinOrFree"
  )
  public final Duration delivered_within_or_free;

  @WireField(
      tag = 6,
      adapter = "com.squareup.wire.ProtoAdapter#STRUCT_MAP",
      label = WireField.Label.OMIT_IDENTITY
  )
  public final Map<String, ?> loyalty;

  @WireField(
      tag = 7,
      adapter = "com.squareup.wire.ProtoAdapter#INSTANT",
      label = WireField.Label.OMIT_IDENTITY,
      jsonName = "orderedAt"
  )
  public final Instant ordered_at;

  public PizzaDelivery(String phone_number, String address, List<Pizza> pizzas,
      AnyMessage promotion, Duration delivered_within_or_free, Map<String, ?> loyalty,
      Instant ordered_at) {
    this(phone_number, address, pizzas, promotion, delivered_within_or_free, loyalty, ordered_at, ByteString.EMPTY);
  }

  public PizzaDelivery(String phone_number, String address, List<Pizza> pizzas,
      AnyMessage promotion, Duration delivered_within_or_free, Map<String, ?> loyalty,
      Instant ordered_at, ByteString unknownFields) {
    super(ADAPTER, unknownFields);
    if (phone_number == null) {
      throw new IllegalArgumentException("phone_number == null");
    }
    this.phone_number = phone_number;
    if (address == null) {
      throw new IllegalArgumentException("address == null");
    }
    this.address = address;
    this.pizzas = Internal.immutableCopyOf("pizzas", pizzas);
    this.promotion = promotion;
    this.delivered_within_or_free = delivered_within_or_free;
    this.loyalty = Internal.immutableCopyOfStruct("loyalty", loyalty);
    this.ordered_at = ordered_at;
  }

  @Override
  public Builder newBuilder() {
    Builder builder = new Builder();
    builder.phone_number = phone_number;
    builder.address = address;
    builder.pizzas = Internal.copyOf(pizzas);
    builder.promotion = promotion;
    builder.delivered_within_or_free = delivered_within_or_free;
    builder.loyalty = loyalty;
    builder.ordered_at = ordered_at;
    builder.addUnknownFields(unknownFields());
    return builder;
  }

  @Override
  public boolean equals(Object other) {
    if (other == this) return true;
    if (!(other instanceof PizzaDelivery)) return false;
    PizzaDelivery o = (PizzaDelivery) other;
    return unknownFields().equals(o.unknownFields())
        && Internal.equals(phone_number, o.phone_number)
        && Internal.equals(address, o.address)
        && pizzas.equals(o.pizzas)
        && Internal.equals(promotion, o.promotion)
        && Internal.equals(delivered_within_or_free, o.delivered_within_or_free)
        && Internal.equals(loyalty, o.loyalty)
        && Internal.equals(ordered_at, o.ordered_at);
  }

  @Override
  public int hashCode() {
    int result = super.hashCode;
    if (result == 0) {
      result = unknownFields().hashCode();
      result = result * 37 + (phone_number != null ? phone_number.hashCode() : 0);
      result = result * 37 + (address != null ? address.hashCode() : 0);
      result = result * 37 + pizzas.hashCode();
      result = result * 37 + (promotion != null ? promotion.hashCode() : 0);
      result = result * 37 + (delivered_within_or_free != null ? delivered_within_or_free.hashCode() : 0);
      result = result * 37 + (loyalty != null ? loyalty.hashCode() : 0);
      result = result * 37 + (ordered_at != null ? ordered_at.hashCode() : 0);
      super.hashCode = result;
    }
    return result;
  }

  public static final class Builder extends Message.Builder<PizzaDelivery, Builder> {
    public String phone_number;

    public String address;

    public List<Pizza> pizzas;

    public AnyMessage promotion;

    public Duration delivered_within_or_free;

    public Map<String, ?> loyalty;

    public Instant ordered_at;

    public Builder() {
      phone_number = "";
      address = "";
      pizzas = Internal.newMutableList();
    }

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

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

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

    public Builder promotion(AnyMessage promotion) {
      this.promotion = promotion;
      return this;
    }

    public Builder delivered_within_or_free(Duration delivered_within_or_free) {
      this.delivered_within_or_free = delivered_within_or_free;
      return this;
    }

    public Builder loyalty(Map<String, ?> loyalty) {
      this.loyalty = loyalty;
      return this;
    }

    public Builder ordered_at(Instant ordered_at) {
      this.ordered_at = ordered_at;
      return this;
    }

    @Override
    public PizzaDelivery build() {
      return new PizzaDelivery(phone_number, address, pizzas, promotion, delivered_within_or_free, loyalty, ordered_at, super.buildUnknownFields());
    }
  }
}
