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

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.mt1xx.mt1XXAbsCreator.MT110AbsCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt1xx.tag.tag110.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

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

public class MT110Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Sender's Reference")
    @TagRegex("16x")
    //20
    private String sendersReference;
    @Status("O")
    @TagName({"53A","53B","53D"})
    @FieldDescription("Sender's Correspondent")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    //53a
    private ActnoBicAdrTagXXX sendersCorrespondent53a;
    @Status("O")
    @TagName({"54A","54B","54D"})
    @FieldDescription("Receiver's Correspondent")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    //54a
    private ActnoBicAdrTagXXX receiversCorrespondent54a;
    @Status("O")
    @TagName("72")
    @FieldDescription("Sender to Receiver Information")
    @TagRegex("6*35x")
    //72
    private String sendertoReceiverInformation;
    //21 30 32a 50a 52a 59a
    private List<MT110AbsCreator> cycleDomain;


    public String getSendersReference() {
        return sendersReference;
    }

    public void setSendersReference(String sendersReference) {
        this.sendersReference = sendersReference;
    }

    public ActnoBicAdrTagXXX getSendersCorrespondent53a() {
        return sendersCorrespondent53a;
    }

    public void setSendersCorrespondent53a(ActnoBicAdrTagXXX sendersCorrespondent53a) {
        this.sendersCorrespondent53a = sendersCorrespondent53a;
    }

    public ActnoBicAdrTagXXX getReceiversCorrespondent54a() {
        return receiversCorrespondent54a;
    }

    public void setReceiversCorrespondent54a(ActnoBicAdrTagXXX receiversCorrespondent54a) {
        this.receiversCorrespondent54a = receiversCorrespondent54a;
    }

    public String getSendertoReceiverInformation() {
        return sendertoReceiverInformation;
    }

    public void setSendertoReceiverInformation(String sendertoReceiverInformation) {
        this.sendertoReceiverInformation = sendertoReceiverInformation;
    }


    public List getCycleDomain() {
        return cycleDomain;
    }

    public void setCycleDomain(List cycleDomain) {
        this.cycleDomain = cycleDomain;
    }


    public MT110Creator() {
        super();
    }

//    public MT110Creator(String jsonData) throws Exception {
//        super(jsonData);
//    }

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



    @Override
    public void pack() {
        //MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList = new ArrayList<>();
        try {
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag53aCreator(this));
            tagCreateList.add(new Tag54aCreator(this));
            tagCreateList.add(new Tag72Creator(this));
            tagCreateList.add(new TagCycleCreator(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;
    }
}
