package at.procon.eventhub.dto;

/**
 * Vehicle registration number reference. VRN/plate is scoped by nation and can
 * be resolved historically by occurredAt later.
 */
public record VehicleRegistrationRefDto(
        String nation,
        String number
) {
    public VehicleRegistrationRefDto {
        nation = normalize(nation);
        number = normalizeNullable(number);
    }

    public boolean hasValue() {
        return number != null && !number.isBlank();
    }

    public String stableKey() {
        return (nation == null ? "" : nation) + ":" + (number == null ? "" : number);
    }

    private static String normalize(String value) {
        return value == null || value.isBlank() ? null : value.trim().toUpperCase();
    }

    private static String normalizeNullable(String value) {
        return value == null || value.isBlank() ? null : value.trim();
    }
}
