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

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.mt7xx.tag.tag761.Tag27Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag761.Tag20Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag761.Tag52aCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag761.Tag77LCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag761.Tag77UCreator;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;
import java.util.ArrayList;
import java.util.List;

/**
 * @author wuzhe
 * @date 2023/2/27
 */
public class MT761Creator extends AbsMTCreator {
    @Status("M")
    @TagName("27")
    @FieldDescription("Sequence of Total")
    @TagRegex("1!n/1!n")
    //27
    private String sequenceofTotal;
    @Status("M")
    @TagName("20")
    @FieldDescription("Undertaking Number")
    @TagRegex("16x")
    //20
    private String undertakingNumber;
    @Status("M")
    @TagName({"52A","52D"})
    @FieldDescription("Issuer")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>4*35x"})
    //52a
    private ActnoBicAdrTagXXX issuer;
    @Status("O")
    @TagName("77U")
    @FieldDescription("Undertaking Terms and Conditions")
    @TagRegex("150*65z")
    //77U
    private String undertakingTermsandConditions;
    @Status("O")
    @TagName("77L")
    @FieldDescription("Requested Local Undertaking Terms and Conditions")
    @TagRegex("150*65z")
    //77L
    private String requestedLocalUndertakingTermsandConditions;

    //27
    public String getSequenceofTotal() {
        return sequenceofTotal;
    }

    public void setSequenceofTotal(String sequenceofTotal) {
        this.sequenceofTotal = sequenceofTotal;
    }

    //20
    public String getUndertakingNumber() {
        return undertakingNumber;
    }

    public void setUndertakingNumber(String undertakingNumber) {
        this.undertakingNumber = undertakingNumber;
    }

    //52a
    public ActnoBicAdrTagXXX getIssuer() {
        return issuer;
    }

    public void setIssuer(ActnoBicAdrTagXXX issuer) {
        this.issuer = issuer;
    }

    //77U
    public String getUndertakingTermsandConditions() {
        return undertakingTermsandConditions;
    }

    public void setUndertakingTermsandConditions(String undertakingTermsandConditions) {
        this.undertakingTermsandConditions = undertakingTermsandConditions;
    }

    //77L
    public String getRequestedLocalUndertakingTermsandConditions() {
        return requestedLocalUndertakingTermsandConditions;
    }

    public void setRequestedLocalUndertakingTermsandConditions(String requestedLocalUndertakingTermsandConditions) {
        this.requestedLocalUndertakingTermsandConditions = requestedLocalUndertakingTermsandConditions;
    }

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

    public MT761Creator() {
        super("761");
    }

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

}

