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.tag775.Tag20Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag775.Tag21Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag775.Tag26ECreator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag775.Tag27Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag775.Tag52aCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag775.Tag77LCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag775.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 MT775Creator 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("21")
    @FieldDescription("Related Referencer")
    @TagRegex("16x")
    //21
    private String relatedReference;
    @Status("M")
    @TagName("26E")
    @FieldDescription("Number of Amendment")
    @TagRegex("3n")
    //26E
    private String numberofAmendment;
    @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("Other Amendments to Undertaking")
    @TagRegex("150*65z")
    //77U
    private String otherAmendmentstoUndertaking;
    @Status("O")
    @TagName("77L")
    @FieldDescription("Other Amendments to Local Undertaking")
    @TagRegex("150*65z")
    //77L
    private String otherAmendmentstoLocalUndertaking;

    //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;
    }

    //21
    public String getRelatedReference() {
        return relatedReference;
    }

    public void setRelatedReference(String relatedReference) {
        this.relatedReference = relatedReference;
    }

    //26E
    public String getNumberofAmendment() {
        return numberofAmendment;
    }

    public void setNumberofAmendment(String numberofAmendment) {
        this.numberofAmendment = numberofAmendment;
    }

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

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

    //77U
    public String getOtherAmendmentstoUndertaking() {
        return otherAmendmentstoUndertaking;
    }

    public void setOtherAmendmentstoUndertaking(String otherAmendmentstoUndertaking) {
        this.otherAmendmentstoUndertaking = otherAmendmentstoUndertaking;
    }

    //77L
    public String getOtherAmendmentstoLocalUndertaking() {
        return otherAmendmentstoLocalUndertaking;
    }

    public void setOtherAmendmentstoLocalUndertaking(String otherAmendmentstoLocalUndertaking) {
        this.otherAmendmentstoLocalUndertaking = otherAmendmentstoLocalUndertaking;
    }

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

    public MT775Creator() {
        super("775");
    }

    /**
     * 需要编写组装报文逻辑，调用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 Tag21Creator(this));
            tagCreateList.add(new Tag26ECreator(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;
    }

}

