matrix.business.pay.selector.PayTemplateSelector Maven / Gradle / Ivy
package matrix.business.pay.selector;
import matrix.boot.common.utils.AssertUtil;
import matrix.business.pay.templates.AbstractTemplate;
import java.util.Map;
/**
* 支付模板选择器
*
* @author wangcheng
* date 2022/12/14
*/
public class PayTemplateSelector {
private final Map templateMap;
public PayTemplateSelector(Map templateMap) {
this.templateMap = templateMap;
}
/**
* 获取模板
*
* @param name 模板名称
* @return 模板
*/
public AbstractTemplate get(String name) {
AbstractTemplate abstractTemplate = templateMap.get(name);
AssertUtil.state(abstractTemplate != null, String.format("%s PayTemplate not found", name));
assert abstractTemplate != null;
return abstractTemplate;
}
}