package cz.senslog.analytics.utils.validator;


import cz.senslog.analytics.domain.Threshold;
import cz.senslog.analytics.utils.validator.domain.ValidationReport;
import cz.senslog.analytics.utils.validator.domain.ValidationResult;

import java.util.function.Supplier;

public interface NotifyTrigger {

    void accept(Threshold threshold, ValidationResult... validationResults);

    Mode mode();
    boolean shouldNotify();
    ValidationReport resultsToNotify();

    enum Mode {
        DISABLED    (DisableNotifyTrigger::new),
        INSTANT     (InstantNotifyTrigger::new),
        ON_CHANGE   (OnChangeNotifyTrigger::new),

        ;

        Mode(Supplier<NotifyTrigger> constructCreator) {
            this.constructCreator = constructCreator;
        }

        private final Supplier<NotifyTrigger> constructCreator;

        public NotifyTrigger createInstance() {
            return constructCreator.get();
        }

        public static Mode of(String mode) {
            return Mode.valueOf(mode.toUpperCase());
        }
    }


}
