package cn.stylefeng.workflow.rule.api.condition;

import lombok.Getter;
import lombok.Setter;
import org.jeasy.rules.api.Facts;
import org.jeasy.rules.api.Rule;

@Getter
@Setter
public abstract class BaseRule<T> implements Rule {

    T result;

    public abstract boolean evaluate(Facts facts);

    public abstract void execute(Facts facts) throws Exception;

    @Override
    public int compareTo(final Rule rule) {
        if (getPriority() < rule.getPriority()) {
            return -1;
        } else if (getPriority() > rule.getPriority()) {
            return 1;
        } else {
            return getName().compareTo(rule.getName());
        }
    }
}
