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

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.mt9xx.mt9XXAbsCreator.MT935AbsCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt9xx.tag.tag935.Tag72Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt9xx.tag.tag935.TagCycleCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt9xx.tag.tag935.Tag20Creator;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

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

/**
 * @author hedonghao
 * @date 2023/2/24
 */
public class MT935Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    //20
    private String transactionReferenceNumber;

    //循环集合
    private List<MT935AbsCreator> mt935AbsCreators;
    @Status("O")
    @TagName("72")
    @FieldDescription("Sender to Receiver Information")
    @TagRegex("6*35x")
    //72
    private String senderReceiverInfo;

    public String getTransactionReferenceNumber() {
        return transactionReferenceNumber;
    }

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

    public List<MT935AbsCreator> getMt935AbsCreators() {
        return mt935AbsCreators;
    }

    public void setMt935AbsCreators(List<MT935AbsCreator> mt935AbsCreators) {
        this.mt935AbsCreators = mt935AbsCreators;
    }

    public String getSenderReceiverInfo() {
        return senderReceiverInfo;
    }

    public void setSenderReceiverInfo(String senderReceiverInfo) {
        this.senderReceiverInfo = senderReceiverInfo;
    }
    public MT935Creator(String msgType)  {
        super(msgType);
    }

    public MT935Creator() {
        super();
    }


    /**
     * 需要编写组装报文逻辑，调用set方法即可
     *
     * @return
     */
    public void pack() {
        // MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList=new ArrayList<>();
        try {
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new TagCycleCreator(this));
            tagCreateList.add(new Tag72Creator(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;
    }


}
