package com.cameleer.server.app.alerting.eval;

import java.util.List;
import java.util.Map;

public sealed interface EvalResult {

    record Firing(Double currentValue, Double threshold, Map<String, Object> context) implements EvalResult {
        public Firing {
            context = context == null ? Map.of() : Map.copyOf(context);
        }
    }

    record Clear() implements EvalResult {
        public static final Clear INSTANCE = new Clear();
    }

    record Error(Throwable cause) implements EvalResult {}

    record Batch(List<Firing> firings, Map<String, Object> nextEvalState) implements EvalResult {
        public Batch {
            firings = firings == null ? List.of() : List.copyOf(firings);
            nextEvalState = nextEvalState == null ? Map.of() : Map.copyOf(nextEvalState);
        }
        /** Convenience: a Batch with no cursor update (first-run empty, or no matches). */
        public static Batch empty() {
            return new Batch(List.of(), Map.of());
        }
    }
}
