package com.brilliance.isc.swift.objmtconvert.model;

import com.brilliance.isc.swift.objmtconvert.ext.XmlDate;
import com.brilliance.isc.swift.objmtconvert.result.MxResult;
import com.prowidesoftware.swift.model.mx.AbstractMX;

import java.util.HashMap;
import java.util.Map;

/**
 * @author gechengyang
 * @date 2023/2/17
 */
public abstract class AbsMXCreator extends AbsCreator {
    public final static String TYPE = "MX";

    protected AbstractMX abstractMX = null;

    private String jsonData;

    private Map jsonMap = new HashMap();

    private String identifier;

    /**
     * 发报行行号
     */
    private String senderBic;

    /**
     * 发报行名称
     */
    private String senderNm;

    /**
     * 收报行行号
     */
    private String receiverBic;

    /**
     * 收报行名称
     */
    private String receiverNm;

    /**
     * 业务编号
     */
    private String bizMsgIdr;

    /**
     * 报文类型定义标识
     */
    private String msgDefIdr;

    /**
     * 交易服务名称
     */
    private String bizSvc;

    /**
     * 创建时间
     */
    private String creDt;

    private MxResult mxResult;

    public AbsMXCreator(String identifier) {
        super(TYPE);
        this.identifier = identifier;
        initAbstractMX();
    }

    public AbsMXCreator() {
        super(TYPE);
    }


    protected void initAbstractMX() {
        String className = "com.prowidesoftware.swift.model.mx.Mx" + identifier.substring(0, 1).toUpperCase() + identifier.substring(1).replaceAll("\\.", "");
        className = className.trim();
        try {
            Object obj = Class.forName(className).newInstance();
            this.abstractMX = (AbstractMX) obj;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public AbstractMX getAbstractMX() {
        return abstractMX;
    }

    public void setAbstractMX(AbstractMX abstractMX) {
        this.abstractMX = abstractMX;
    }

    public String getJsonData() {
        return jsonData;
    }

    public void setJsonData(String jsonData) {
        this.jsonData = jsonData;
    }

    public Map getJsonMap() {
        return jsonMap;
    }

    public void setJsonMap(Map jsonMap) {
        this.jsonMap = jsonMap;
    }

    public String getIdentifier() {
        return identifier;
    }

    public void setIdentifier(String identifier) {
        this.identifier = identifier;
    }

    public String getSenderBic() {
        return senderBic;
    }

    public void setSenderBic(String senderBic) {
        this.senderBic = senderBic;
    }

    public String getSenderNm() {
        return senderNm;
    }

    public void setSenderNm(String senderNm) {
        this.senderNm = senderNm;
    }

    public String getReceiverBic() {
        return receiverBic;
    }

    public void setReceiverBic(String receiverBic) {
        this.receiverBic = receiverBic;
    }

    public String getReceiverNm() {
        return receiverNm;
    }

    public void setReceiverNm(String receiverNm) {
        this.receiverNm = receiverNm;
    }

    public String getBizMsgIdr() {
        return bizMsgIdr;
    }

    public void setBizMsgIdr(String bizMsgIdr) {
        this.bizMsgIdr = bizMsgIdr;
    }

    public String getMsgDefIdr() {
        return msgDefIdr;
    }

    public void setMsgDefIdr(String msgDefIdr) {
        this.msgDefIdr = msgDefIdr;
    }

    public String getBizSvc() {
        return bizSvc;
    }

    public void setBizSvc(String bizSvc) {
        this.bizSvc = bizSvc;
    }

    public String getCreDt() {
        return creDt;
    }


    public void setCreDt(XmlDate creDt) {
        this.creDt = creDt.getDateStr();
    }

    public MxResult getMxResult() {
        return mxResult;
    }

    public void setMxResult(MxResult mxResult) {
        this.mxResult = mxResult;
    }

    public void pack() {

    }
}
