package org.xyzh.crontab.enums;

import java.util.Arrays;

import org.xyzh.crontab.task.newsTask.NewsCrawlerTask;

// import org.xyzh.crontab.task.DataBackupTask;
// import org.xyzh.crontab.task.LogCleanTask;
// import org.xyzh.crontab.task.SystemStatisticsTask;

public enum TaskEnums {
    // DATA_BACKUP("dataBackup", DataBackupTask.class),
    // LOG_CLEAN("logClean", LogCleanTask.class),
    // SystemStatistics("systemStatistics", SystemStatisticsTask.class);
    NEWS_CRAWLER("newsCrawler", NewsCrawlerTask.class);


    private String name;
    private Class<?> clazz;

    TaskEnums(String name, Class<?> clazz) {
        this.name = name;
        this.clazz = clazz;
    }

    public String getName() {
        return name;
    }

    public Class<?> getClazz() {
        return clazz;
    }

    public static TaskEnums getByName(String name) {
        return Arrays.stream(TaskEnums.values())
            .filter(task -> task.getName().equals(name))
            .findFirst()
            .orElse(null);
    }
}
