All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.neko233.skilltree.scheduler.client.helper.TaskSchedulerHelper Maven / Gradle / Ivy

There is a newer version: 0.3.6
Show newest version
package com.neko233.skilltree.scheduler.client.helper;

import com.neko233.skilltree.annotation.NotNull;
import com.neko233.skilltree.scheduler.client.annotation.ScheduleTask;
import org.apache.commons.lang3.StringUtils;

import java.lang.reflect.Method;

public class TaskSchedulerHelper {


    @NotNull
    public static String getTaskNameOrDefault(ScheduleTask scheduleTask,
                                              Class clazz,
                                              Method method) {
        String taskName = scheduleTask.taskName();
        if (StringUtils.isBlank(taskName)) {
            taskName = clazz.getName() + "::" + method.getName();
        }
        return taskName;
    }


    /**
     * 调度任务名
     *
     * @param scheduleTask 调度任务
     * @param object       对象
     * @param method       方法
     * @return 调度任务 key
     */
    @NotNull
    public static String getTaskNameOrDefault(ScheduleTask scheduleTask,
                                              Object object,
                                              Method method) {
        return getTaskNameOrDefault(scheduleTask, object.getClass(), method);
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy