package com.jsowell.netty.factory;

import com.google.common.collect.Maps;
import com.jsowell.common.util.StringUtils;
import com.jsowell.netty.handler.AbstractHandler;

import java.util.Map;
import java.util.Objects;

/**
 * 工厂设计模式
 * 云快充操作
 */
public class YKCOperateFactory {

	private static Map<String, AbstractHandler> strategyMap = Maps.newHashMap();

	/**
	 * 注册
	 * @param str
	 * @param handler
	 */
	public static void register(String str, AbstractHandler handler) {
		if (StringUtils.isBlank(str) || Objects.isNull(handler)) {
			return;
		}
		strategyMap.put(str, handler);
	}

	/**
	 * 获取
	 * @param name
	 * @return
	 */
	public static AbstractHandler getInvokeStrategy(String name) {
		return strategyMap.get(name);
	}
}
