
package com.lideeyunji.core.framework.config.aspect.enhancereport.plugin;

import com.lideeyunji.core.framework.config.aspect.enhancereport.model.EnhanceReportContext;

import java.util.HashMap;
import java.util.Map;


public class ReportPluginManager {

    public static Map<String, ReportBaseAdvicePlugin> plugins = new HashMap<>();


    public static ReportBaseAdvicePlugin getPlugin(String key){
        return plugins.get(key);
    }


    public static void addPlugin(String key, ReportBaseAdvicePlugin plugin){
        plugins.put(key,plugin);
    }

    public static void addPlugin(ReportBaseAdvicePlugin plugin){
        plugins.put(plugin.getClass().getName(),  plugin);
    }

    public static boolean removePlugin(String name){
        plugins.remove(name);
        return true;
    }

    public static void executePlugin(String name, EnhanceReportContext enhanceContext){
        ReportBaseAdvicePlugin plugin = plugins.get(name);
        plugin.execute(enhanceContext);
    }

    public static void executePlugin(ReportBaseAdvicePlugin plugin, EnhanceReportContext enhanceContext){
        plugin.execute(enhanceContext);
    }

}