23 lines
1.3 KiB
Java
23 lines
1.3 KiB
Java
package com.baiyue.lastleg.appointmentplanning;
|
|||
|
|
|
||
|
|
import java.util.Objects;
|
||
|
|
|
||
|
|
/** Source-local observations can prove a change, not a cross-time-zone delivery violation. */
|
||
|
|
public final class AppointmentImpactPolicy {
|
||
|
|
private AppointmentImpactPolicy() { }
|
||
|
|
public record Decision(boolean reviewRequired,String reason) { }
|
||
|
|
public static Decision compare(AppointmentForecastClient.Fact baseline,AppointmentForecastClient.Fact latest) {
|
||
|
|
if(latest==null || latest.estimatedAt()==null && latest.actualAt()==null) return new Decision(true,"FORECAST_MISSING");
|
||
|
|
if(latest.actualAt()!=null) {
|
||
|
|
return baseline==null || !Objects.equals(baseline.actualAt(),latest.actualAt())
|
||
|
|
? new Decision(true,"ACTUAL_ARRIVAL_REVIEW") : new Decision(false,"UNCHANGED");
|
||
|
|
}
|
||
|
|
if(baseline==null) return new Decision(false,"BASELINE_ESTABLISHED");
|
||
|
|
if(!Objects.equals(baseline.estimatedAt(),latest.estimatedAt()) || !Objects.equals(baseline.actualAt(),latest.actualAt()))
|
||
|
|
return new Decision(true,"FORECAST_CHANGED");
|
||
|
|
if(!Objects.equals(baseline.providerCode(),latest.providerCode()) || !Objects.equals(baseline.sourceReference(),latest.sourceReference()))
|
||
|
|
return new Decision(true,"SOURCE_CHANGED");
|
||
|
|
return new Decision(false,"UNCHANGED");
|
||
|
|
}
|
||
|
|
}
|