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

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

import com.xisc.pm.app.service.strategy.formplatemode.FormPlateModeStrategy;
import com.xisc.pm.infra.enums.FormPlateMode;

/**
 * 组板方式策略工厂
 * @author jun.zeng
 *
 */
public class FormPlateModeStrategyFactory {

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

    public static FormPlateModeStrategy matchStrategy(FormPlateMode mode) {
        return services.get(mode.getCode());
    }
    
    public static FormPlateModeStrategy matchStrategy(String code) {
        return services.get(code);
    }

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

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