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

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

public class MT996Creator 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;

    //76
    @Status("M")
    @TagName("76")
    @FieldDescription("Answers")
    @TagRegex("6*35x")
    private String answers;

    //77A
    @Status("O")
    @TagName("77A")
    @FieldDescription("Narrative")
    @TagRegex("20*35x")
    private String narrative;

    @Status("O")
    @TagName("11S")
    @FieldDescription("MT and Date of the Original Message")
    @TagRegex("3!n\r\n6!n\r\n[4!n6!n]")
    //11a
    //有11R和11S两个选项。先按11S处理。后续会需要修改tag196.Tag11aCreator类。
    private String mtDateTag11a;

    //11a  R/S
    @Status("O")
    @TagName("11R")
    @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 to Which the Answer Relates")
    @TagRegex("35*50x")
    private String narrativeDescription;

    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 getAnswers() {
        return answers;
    }

    public void setAnswers(String answers) {
        this.answers = answers;
    }

    public String getNarrative() {
        return narrative;
    }

    public void setNarrative(String narrative) {
        this.narrative = narrative;
    }

    public String getMtDateTag11a() {
        return mtDateTag11a;
    }

    public void setMtDateTag11a(String mtDateTag11a) {
        this.mtDateTag11a = mtDateTag11a;
    }

    public String getMtAndDateoftheOriginalMessage() {
        return mtAndDateoftheOriginalMessage;
    }

    public void setMtAndDateoftheOriginalMessage(String mtAndDateoftheOriginalMessage) {
        this.mtAndDateoftheOriginalMessage = mtAndDateoftheOriginalMessage;
    }

    public String getNarrativeDescription() {
        return narrativeDescription;
    }

    public void setNarrativeDescription(String narrativeDescription) {
        this.narrativeDescription = narrativeDescription;
    }

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

    public MT996Creator() {
        super("996");
    }

    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 Tag76Creator(this));
            tagCreateList.add(new Tag77ACreator(this));
            tagCreateList.add(new Tag11rCreator(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;
    }
}


