package com.jsowell.pile.service.orderlogic;

import com.google.common.collect.Maps;
import com.jsowell.common.util.StringUtils;

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

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

	private static Map<String, AbstractOrderLogic> orderLogicMap = Maps.newHashMap();

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

	/**
	 * 获取
	 * @param name
	 * @return
	 */
	public static AbstractOrderLogic getOrderLogic(String name) {
		return orderLogicMap.get(name);
	}
}
