package com.engine.htsc.branchpayment.service.impl;

import com.engine.htsc.branchpayment.enums.BranchPay;
import com.engine.htsc.payment.service.BudgetCommand;
import com.engine.htsc.subpayment.enums.SubPay;

/**
 * 动态获取预算command
 */
public class BranchBudgetCommandFactory {

  private BranchBudgetCommandFactory() {
  }

  // 分支
  public static BudgetCommand getBudgetCommand(String type) {
    try {
      return (BudgetCommand) Class.forName(BranchPay.getClassByType(type)).newInstance();
    } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) {
      e.printStackTrace();
    }
    return null;
  }

  // 子公司
  public static BudgetCommand getBudgetCommand4Sub(String type) {
    try {
      return (BudgetCommand) Class.forName(SubPay.getClassByType(type)).newInstance();
    } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) {
      e.printStackTrace();
    }
    return null;
  }

}
