package com.jsowell.thirdparty.platform.factory;

import com.google.common.collect.Maps;
import com.jsowell.common.util.StringUtils;
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;

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

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

	private static Map<String, ThirdPartyPlatformService> serviceMap = Maps.newHashMap();

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

	/**
	 * 获取
	 * @param type
	 * @return
	 */
	public static ThirdPartyPlatformService getInvokeStrategy(String type) {
		return serviceMap.get(type);
	}
}
