package com.lingniu.ingest.vehiclestat;

import java.time.LocalDate;
import java.util.OptionalDouble;

public record VehicleDailyStatResult(String vin,
                                     LocalDate statDate,
                                     OptionalDouble dailyMileageKm,
                                     DailyMileageStrategy dailyMileageStrategy) {

    public VehicleDailyStatResult {
        if (vin == null || vin.isBlank()) {
            throw new IllegalArgumentException("vin must not be blank");
        }
        if (statDate == null) {
            throw new IllegalArgumentException("statDate must not be null");
        }
        if (dailyMileageKm == null) {
            dailyMileageKm = OptionalDouble.empty();
        }
        if (dailyMileageStrategy == null) {
            dailyMileageStrategy = DailyMileageStrategy.JT808_TOTAL_MILEAGE_DIFF;
        }
    }
}
