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

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

/**
 * @author zh
 * @create 2023-02-27-17:28
 */
public class MT422Creator extends AbsMTCreator {

    private List<MT422AbsCreator> mt422AbsCreators;

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

    @Status("O")
    @TagName("75")
    @FieldDescription("Queries")
    @TagRegex("6*35x")
    private String queries;

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

    public List<MT422AbsCreator> getMt422AbsCreators() {
        return mt422AbsCreators;
    }

    public void setMt422AbsCreators(List<MT422AbsCreator> mt422AbsCreators) {
        this.mt422AbsCreators = mt422AbsCreators;
    }

    public String getSenderToReceiverInformation() {
        return senderToReceiverInformation;
    }

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

    public String getQueries() {
        return queries;
    }

    public void setQueries(String queries) {
        this.queries = queries;
    }

    public String getAnswers() {
        return answers;
    }

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

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

    public MT422Creator() {
        super();
    }


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