package com.zd.laboratory.event.handle;

import cn.hutool.core.util.StrUtil;

import java.util.function.Consumer;
import java.util.function.Function;

/**
 * @Author: zhoupan
 * @Date: 2021/11/07/10:40
 * @Description:
 */
public interface EventHandler {

    default void handle(String value)
    {
        eventHandler().accept(keyToValue().apply(value));
    }

    default Function<String,String>  keyToValue()
    {
        return s ->StrUtil.subAfter(s, handleKey(), false);
    }

    Consumer<String> eventHandler();

    String handleKey();

}
