package de.effigenix.domain.masterdata.customer;

import de.effigenix.shared.common.Address;
import de.effigenix.shared.common.Result;

/**
 * Value Object representing a labeled delivery address.
 */
public record DeliveryAddress(
        String label,
        Address address,
        String contactPerson,
        String deliveryNotes
) {

    public DeliveryAddress {
        if (address == null) {
            throw new IllegalArgumentException("Address must not be null");
        }
    }

    public static Result<String, DeliveryAddress> create(
            String label, Address address, String contactPerson, String deliveryNotes) {
        try {
            return Result.success(new DeliveryAddress(label, address, contactPerson, deliveryNotes));
        } catch (IllegalArgumentException e) {
            return Result.failure(e.getMessage());
        }
    }
}
