/// Postanschrift — Value-Object, identitätslos.
///
/// Tritt im Domain an drei Stellen auf: am `Customer` (Stamm-Adresse) und
/// als `deliveryAddressSnapshot` auf der `Delivery` (eingefrorene Kopie der
/// Adresse zum Zeitpunkt der Belegerzeugung, damit nachträgliche Änderungen
/// am Stammdatensatz die ausgelieferte Tour nicht „verschieben"). Spiegelt
/// das Backend-DTO `Address` 1:1.
class Address {
  const Address({
    required this.street,
    required this.houseNumber,
    required this.postalCode,
    required this.city,
    required this.country,
  });

  final String street;
  final String houseNumber;
  final String postalCode;
  final String city;
  final String country;

  /// Einzeilige Darstellung für Listen/Header.
  String get oneLine =>
      '$street $houseNumber, $postalCode $city';

  Address copyWith({
    String? street,
    String? houseNumber,
    String? postalCode,
    String? city,
    String? country,
  }) {
    return Address(
      street: street ?? this.street,
      houseNumber: houseNumber ?? this.houseNumber,
      postalCode: postalCode ?? this.postalCode,
      city: city ?? this.city,
      country: country ?? this.country,
    );
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is Address &&
          other.street == street &&
          other.houseNumber == houseNumber &&
          other.postalCode == postalCode &&
          other.city == city &&
          other.country == country;

  @override
  int get hashCode => Object.hash(street, houseNumber, postalCode, city, country);
}
