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

top.jiaojinxin.jln.event.EventHandler Maven / Gradle / Ivy

There is a newer version: 0.1.7
Show newest version
package top.jiaojinxin.jln.event;

/**
 * 事件处理器
 *
 * @author JiaoJinxin
 */
public interface EventHandler {

    /**
     * 处理事件
     *
     * @param event 事件
     * @author JiaoJinxin
     */
    void doHandle(E event);

    /**
     * 事件Class
     *
     * @return java.lang.Class
     * @author JiaoJinxin
     */
    Class eventClass();

    /**
     * 处理事件
     *
     * @param event 事件
     * @author JiaoJinxin
     */
    default void handle(Event event) {
        if (eventClass().isAssignableFrom(event.getClass())) {
            doHandle((E) event);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy