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

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

/**
 * @Description：
 * @Author：夏猛
 * @CreateTime：2023/2/28 15:04
 **/
public class MT292Creator extends AbsMTCreator {
    //20
    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    private String transactionReferenceNumber;

    //21
    @Status("M")
    @TagName("21")
    @FieldDescription("Related Reference")
    @TagRegex("16x")
    private String relatedReference;

    //11S
    @Status("M")
    @TagName("11S")
    @FieldDescription("MT and Date of the Original Message")
    @TagRegex("3!n<crlf>6!n<crlf>[4!n6!n]")
    private String MTandDateoftheOriginalMessage;

    //79
    @Status("O")
    @TagName("79")
    @FieldDescription("Narrative Description of the Original Message")
    @TagRegex("35*50x")
    private String narrativeDescriptionoftheOriginalMessage;

    //
//    @Status("O")
//    @TagName("")
//    @FieldDescription("Copy of at least the Mandatory Fields of the Original Message")
//    @TagRegex("")
//    public String copyofatleasttheMandatoryFieldsoftheOriginalMessage;

    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 String getMTandDateoftheOriginalMessage() {
        return MTandDateoftheOriginalMessage;
    }

    public void setMTandDateoftheOriginalMessage(String MTandDateoftheOriginalMessage) {
        this.MTandDateoftheOriginalMessage = MTandDateoftheOriginalMessage;
    }

    public String getNarrativeDescriptionoftheOriginalMessage() {
        return narrativeDescriptionoftheOriginalMessage;
    }

    public void setNarrativeDescriptionoftheOriginalMessage(String narrativeDescriptionoftheOriginalMessage) {
        this.narrativeDescriptionoftheOriginalMessage = narrativeDescriptionoftheOriginalMessage;
    }

//    public String getCopyofatleasttheMandatoryFieldsoftheOriginalMessage() {
//        return copyofatleasttheMandatoryFieldsoftheOriginalMessage;
//    }
//
//    public void setCopyofatleasttheMandatoryFieldsoftheOriginalMessage(String copyofatleasttheMandatoryFieldsoftheOriginalMessage) {
//        this.copyofatleasttheMandatoryFieldsoftheOriginalMessage = copyofatleasttheMandatoryFieldsoftheOriginalMessage;
//    }

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

    public MT292Creator() {
        super();
    }

    public void pack() {
      //  MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList=new ArrayList<>();
        try {
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag21Creator(this));
            tagCreateList.add(new Tag11SCreator(this));
            tagCreateList.add(new Tag79Creator(this));
          //  tagCreateList.add(new TagCreator(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;
    }
}


