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.mt2XXAbsCreator.MT210AbsCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.tag.tag210.Tag20Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.tag.tag210.Tag25Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.tag.tag210.Tag30Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.tag.tag210.TagCycleCreator;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

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

/**
 * @author huangmengyuan
 * @create 2023/2/28
 */
public class MT210Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    //20
    private String transactionReferenceNumber;
    @Status("O")
    @TagName("25")
    @FieldDescription("Account Identification")
    @TagRegex("35x")
    //25
    private String accountIdentification;
    @Status("M")
    @TagName("30")
    @FieldDescription("Value Date")
    @TagRegex("6!n")
    //30
    private String valueDate;
    //循环域
    private List<MT210AbsCreator> cycleDomain;

    public String getTransactionReferenceNumber() {
        return transactionReferenceNumber;
    }

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

    public String getAccountIdentification() {
        return accountIdentification;
    }

    public void setAccountIdentification(String accountIdentification) {
        this.accountIdentification = accountIdentification;
    }

    public String getValueDate() {
        return valueDate;
    }

    public void setValueDate(String valueDate) {
        this.valueDate = valueDate;
    }

    public List<MT210AbsCreator> getCycleDomain() {
        return cycleDomain;
    }

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

    public MT210Creator() {
    }

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


    public MT210Creator(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 Tag25Creator(this));
            tagCreateList.add(new Tag30Creator(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;
    }
}
