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.tag998.Tag12Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt9xx.tag.tag998.Tag20Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt9xx.tag.tag998.Tag77ECreator;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

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

public class MT998Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    //20
    private String transactionReferenceNumber;
    @Status("M")
    @TagName("12")
    @FieldDescription("Sub-Message Type")
    @TagRegex("3!n")
    //12
    private String subMessageType;
    @Status("M")
    @TagName("77E")
    @FieldDescription("Proprietary Message")
    @TagRegex("73z<crlf>[n*78z]")
    //77E
    private String proprietaryMessage;

    public String getTransactionReferenceNumber() {
        return transactionReferenceNumber;
    }

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

    public String getSubMessageType() {
        return subMessageType;
    }

    public void setSubMessageType(String subMessageType) {
        this.subMessageType = subMessageType;
    }

    public String getProprietaryMessage() {
        return proprietaryMessage;
    }

    public void setProprietaryMessage(String proprietaryMessage) {
        this.proprietaryMessage = proprietaryMessage;
    }

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

    public MT998Creator() {
    }

    @Override
    public void pack() {
        //MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList=new ArrayList<>();
        try{
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag12Creator(this));
            tagCreateList.add(new Tag77ECreator(this));
            dealTags(tagCreateList);
            mtResult.setMessage(abstractMT.message());
        }catch (Exception e) {
            e.printStackTrace();
            mtResult.setSuccess(false);
            mtResult.addDescription(e.getLocalizedMessage());
        }

        //return mtResult;
    }
}
