package com.r35157.jupiterperpsalarm.impl.ref;

import java.util.Objects;

public record PriceAlarmDefinition(
        int id,
        JupiterPerpsAsset asset,
        String conditionExpression,
        AlarmTrigger trigger,
        ΩmilliSecondsΩ triggerGracePeriod
) {
    public PriceAlarmDefinition {
        Objects.requireNonNull(asset, "asset");
        Objects.requireNonNull(conditionExpression, "conditionExpression");
        Objects.requireNonNull(trigger, "trigger");

        if (conditionExpression.isBlank()) {
            throw new IllegalArgumentException("Condition expression cannot be blank");
        }

        if (triggerGracePeriod < 0) {
            throw new IllegalArgumentException(
                    "Trigger grace period cannot be negative: " + triggerGracePeriod
            );
        }
    }
}
