package xyz.wbsite.frame.schedule;

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.util.Assert;

import java.util.concurrent.ScheduledFuture;

public abstract class RunCronTask extends RunTask {

    abstract String cron();

    @Override
    public ScheduledFuture<?> schedule(ThreadPoolTaskScheduler poolTaskScheduler) {
        Assert.notNull(poolTaskScheduler, "ThreadPoolTaskScheduler must not be null");
        return poolTaskScheduler.schedule(this, new CronTrigger(cron()));
    }
}
