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

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.mt4xx.mt4XXAbsCreator.MT420AbsCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt4xx.tag.tag420.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

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

/**
 * @author zh
 * @create 2023-03-01-14:54
 */
public class MT420Creator extends AbsMTCreator {

    private List<MT420AbsCreator> mt420AbsCreators;

    @Status("O")
    @TagName("30")
    @FieldDescription("Date of Collection Instruction")
    @TagRegex("6!n")
    private String dateOfCollectionInstruction;

    @Status("O")
    @TagName("59")
    @FieldDescription("Drawee")
    @TagRegex("[/34x]<crlf>4*35x")
    private ActnoBicAdrTagXXX drawee;

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

    public List<MT420AbsCreator> getMt420AbsCreators() {
        return mt420AbsCreators;
    }

    public void setMt420AbsCreators(List<MT420AbsCreator> mt420AbsCreators) {
        this.mt420AbsCreators = mt420AbsCreators;
    }

    public String getDateOfCollectionInstruction() {
        return dateOfCollectionInstruction;
    }

    public void setDateOfCollectionInstruction(String dateOfCollectionInstruction) {
        this.dateOfCollectionInstruction = dateOfCollectionInstruction;
    }

    public ActnoBicAdrTagXXX getDrawee() {
        return drawee;
    }

    public void setDrawee(ActnoBicAdrTagXXX drawee) {
        this.drawee = drawee;
    }

    public String getSenderToReceiverInformation() {
        return senderToReceiverInformation;
    }

    public void setSenderToReceiverInformation(String senderToReceiverInformation) {
        this.senderToReceiverInformation = senderToReceiverInformation;
    }
    public MT420Creator(String msgType)  {
        super(msgType);
    }

    public MT420Creator() {
        super();
    }


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