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

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.tag202common.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

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


public class MT202Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    //20
    private String transactionReferenceNumber;
    @Status("M")
    @TagName("21")
    @FieldDescription("Related Reference")
    @TagRegex("16x")
    //21
    private String relatedReference;
    @Status("O")
    @TagName("13C")
    @FieldDescription("Time Indication")
    @TagRegex("/8c/4!n1!x4!n")
    //13C
    private LinkedList timeIndication;
    @Status("M")
    @TagName("32A")
    @FieldDescription("Value Date, Currency Code, Amount")
    @TagRegex("6!n3!a15d")
    //32A
    private DcDateCurAmtTagXXX valueDateCurrencyAmount;
    @Status("O")
    @TagName({"52A","52D"})
    @FieldDescription("Ordering Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>4*35x"})
    //52a
    private ActnoBicAdrTagXXX orderingInstitution;
    @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 sendersCorrespondent;
    @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 receiversCorrespondent;
    @Status("O")
    @TagName({"56A","56D"})
    @FieldDescription("Intermediary")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>4*35x"})
    //56a
    private ActnoBicAdrTagXXX intermediary;
    @Status("O")
    @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"})
    //57a
    private ActnoBicAdrTagXXX accountWithInstitution;
    @Status("M")
    @TagName({"58A","58D"})
    @FieldDescription("Beneficiary Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>4*35x"})
    //58a
    private ActnoBicAdrTagXXX beneficiaryInstitution;
    @Status("O")
    @TagName("72")
    @FieldDescription("Sender to Receiver Information")
    @TagRegex("6*35x")
    //72
    private String senderToReceiverInformation;

    public String getTransactionReferenceNumber() {
        return transactionReferenceNumber;
    }

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

    public String getRelatedReference() {
        return relatedReference;
    }

    public void setRelatedReference(String relatedReference) {
        this.relatedReference = relatedReference;
    }

    public LinkedList getTimeIndication() {
        return timeIndication;
    }

    public void setTimeIndication(LinkedList timeIndication) {
        this.timeIndication = timeIndication;
    }

    public DcDateCurAmtTagXXX getValueDateCurrencyAmount() {
        return valueDateCurrencyAmount;
    }

    public void setValueDateCurrencyAmount(DcDateCurAmtTagXXX valueDateCurrencyAmount) {
        this.valueDateCurrencyAmount = valueDateCurrencyAmount;
    }

    public ActnoBicAdrTagXXX getOrderingInstitution() {
        return orderingInstitution;
    }

    public void setOrderingInstitution(ActnoBicAdrTagXXX orderingInstitution) {
        this.orderingInstitution = orderingInstitution;
    }

    public ActnoBicAdrTagXXX getSendersCorrespondent() {
        return sendersCorrespondent;
    }

    public void setSendersCorrespondent(ActnoBicAdrTagXXX sendersCorrespondent) {
        this.sendersCorrespondent = sendersCorrespondent;
    }

    public ActnoBicAdrTagXXX getReceiversCorrespondent() {
        return receiversCorrespondent;
    }

    public void setReceiversCorrespondent(ActnoBicAdrTagXXX receiversCorrespondent) {
        this.receiversCorrespondent = receiversCorrespondent;
    }

    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 ActnoBicAdrTagXXX getBeneficiaryInstitution() {
        return beneficiaryInstitution;
    }

    public void setBeneficiaryInstitution(ActnoBicAdrTagXXX beneficiaryInstitution) {
        this.beneficiaryInstitution = beneficiaryInstitution;
    }

    public String getSenderToReceiverInformation() {
        return senderToReceiverInformation;
    }

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

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

    public MT202Creator() {
        super("202");
    }

    @Override
    public void pack() {
        //MtResult mtResult = new MtResult();
//        List<AbsTagCreate> tagCreateList = new ArrayList();
        try {
            dealTags(addTagList());
            mtResult.setMessage(abstractMT.message());
        } catch (Exception e) {
            e.printStackTrace();
            mtResult.setSuccess(false);
            mtResult.addDescription(e.getLocalizedMessage());
        }

        //return mtResult;
    }

    public List addTagList() {
        List<AbsTagCreate> tagCreateList = new ArrayList();
        tagCreateList.add(new Tag13CCreator(this));
        tagCreateList.add(new Tag20Creator(this));
        tagCreateList.add(new Tag21Creator(this));
        tagCreateList.add(new Tag32ACreator(this));
        tagCreateList.add(new Tag52aCreator(this));
        tagCreateList.add(new Tag53aCreator(this));
        tagCreateList.add(new Tag54aCreator(this));
        tagCreateList.add(new Tag56aCreator(this));
        tagCreateList.add(new Tag57aCreator(this));
        tagCreateList.add(new Tag58aCreator(this));
        tagCreateList.add(new Tag72Creator(this));

        return tagCreateList;
    }


}
