package com.brilliance.isc.swift.objmtconvert.model.busvalidator.mt4xx;

import com.brilliance.isc.swift.objmtconvert.model.AbsMTValidator;
import com.brilliance.isc.swift.objmtconvert.model.busvalidator.ValidatorMethod;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;
import com.brilliance.isc.swift.objmtconvert.util.Language;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.field.*;
import com.prowidesoftware.swift.model.mt.mt4xx.MT422;

import java.util.List;

/**
 * @author zh
 * @create 2023-03-03-10:27
 */
public class MT422Validator extends AbsMTValidator {

    public MT422Validator(String mtStr, MtResult mtResult)
    {
        super(mtStr,mtResult);
    }

    @Override
    public void bussinessValidator() {
        //MtResult mtResult=getMtResult();
        List<Tag> tags = this.getAbstractMT().getSwiftMessage().getBlock4().getTags();
        String msgType = "MT422";
        mtResult = ValidatorMethod.mt4xxField202132(tags,mtResult,msgType);
        MT422 mt422 = (MT422) this.getAbstractMT();
        List<Field32A> listField32A = mt422.getField32A();
        List<Field32B> listField32B = mt422.getField32B();
        List<Field32K> listField32K = mt422.getField32K();
        int count = 0;
        Field72 field72 = mt422.getField72();
        Field75 field75 = mt422.getField75();
        Field76 field76 = mt422.getField76();
        if(field72!=null){
            count++;
        }
        if(field75!=null){
            count++;
        }
        if(field76!=null){
            count++;
        }
        if(count<1){
            mtResult.addDescription(Language.getLanguage("MT422_C2","【MT422】"));
        }
        mtResult = ValidatorMethod.mt4xxField32(listField32A, listField32B, listField32K, mtResult,msgType);
        //return mtResult;
    }
}
