package com.xisc.pm.app.service.strategy;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.xisc.pm.app.service.strategy.pdevent.PdEventStrategy;
import com.xisc.pm.infra.enums.PdEventType;

/**
 * 事件策略工厂类
 * @author jun.zeng
 *
 */
public class PdEventStrategyFactory {

    private static Map<String, PdEventStrategy> services = new ConcurrentHashMap<String, PdEventStrategy>();

    public static PdEventStrategy matchPdEventStrategy(PdEventType eventType) {
        return services.get(eventType.getCode());
    }

    /**
     * 注册事件策略策略
     * 
     * @param policy
     * @param calcStrategy
     */
    public static void register(PdEventType eventType, PdEventStrategy pdEventStrategy) {
        services.put(eventType.getCode(), pdEventStrategy);
    }

    /**
     * @return the services
     */
    public static Map<String, PdEventStrategy> getServices() {
        return services;
    }

}
