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

import com.brilliance.isc.swift.objmtconvert.annotation.FieldDescription;
import com.brilliance.isc.swift.objmtconvert.annotation.Status;
import com.brilliance.isc.swift.objmtconvert.annotation.TagName;
import com.brilliance.isc.swift.objmtconvert.annotation.TagRegex;
import com.brilliance.isc.swift.objmtconvert.model.AbsMTCreator;
import com.brilliance.isc.swift.objmtconvert.model.AbsTagCreate;
import com.brilliance.isc.swift.objmtconvert.model.commontag.ActnoBicAdrTagXXX;
import com.brilliance.isc.swift.objmtconvert.model.commontag.DcDateCurAmtTagXXX;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.tag.tag201.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description：
 * @Author：夏猛
 * @CreateTime：2023/2/24 15:58
 **/
public class MT201AbsCreator extends AbsMTCreator {

    //20
    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    private String transactionReferenceNumber;

    //32B
    @Status("M")
    @TagName("32B")
    @FieldDescription("Currency Code, Amount")
    @TagRegex("3!a15d")
    private DcDateCurAmtTagXXX currencyCodeAmount;

    //56a
    @Status("O")
    @TagName({"56A","57D"})
    @FieldDescription("Intermediary")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX intermediary;

    //57a
    @Status("M")
    @TagName({"57A","57B","57D"})
    @FieldDescription("Account With Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX accountWithInstitution;

    //72
    @Status("O")
    @TagName("72")
    @FieldDescription("Sender to Receiver Information")
    @TagRegex("6*35x")
    private String sendertoReceiverInformationB;

    public String getTransactionReferenceNumber() {
        return transactionReferenceNumber;
    }

    public void setTransactionReferenceNumber(String transactionReferenceNumber) {
        this.transactionReferenceNumber = transactionReferenceNumber;
    }

    public DcDateCurAmtTagXXX getCurrencyCodeAmount() {
        return currencyCodeAmount;
    }

    public void setCurrencyCodeAmount(DcDateCurAmtTagXXX currencyCodeAmount) {
        this.currencyCodeAmount = currencyCodeAmount;
    }

    public ActnoBicAdrTagXXX getIntermediary() {
        return intermediary;
    }

    public void setIntermediary(ActnoBicAdrTagXXX intermediary) {
        this.intermediary = intermediary;
    }

    public ActnoBicAdrTagXXX getAccountWithInstitution() {
        return accountWithInstitution;
    }

    public void setAccountWithInstitution(ActnoBicAdrTagXXX accountWithInstitution) {
        this.accountWithInstitution = accountWithInstitution;
    }

    public String getSendertoReceiverInformationB() {
        return sendertoReceiverInformationB;
    }

    public void setSendertoReceiverInformationB(String sendertoReceiverInformationB) {
        this.sendertoReceiverInformationB = sendertoReceiverInformationB;
    }

    public MT201AbsCreator(String msgType)  {
        super(msgType);
    }

    public MT201AbsCreator() {
        super();
    }

    public void pack() {
      //  MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList=new ArrayList<>();
        try {
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag32BCreator(this));
            tagCreateList.add(new Tag56aCreator(this));
            tagCreateList.add(new Tag57aCreator(this));
            tagCreateList.add(new TagB72Creator(this));
            dealTags(tagCreateList);

            mtResult.setMessage(abstractMT.message());
        } catch (Exception e) {
            e.printStackTrace();
            mtResult.setSuccess(false);
            mtResult.addDescription(e.getLocalizedMessage());
        }

        // return mtResult;

    }

    public MtResult unpack() {
        return null;
    }
}
