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


import com.brilliance.isc.swift.objmtconvert.model.AbsMTValidator;
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.mt.mt7xx.MT707;
import java.util.List;
import java.util.Objects;

/**
 * MT750
 * @author wanggang
 * @Date 2023-3-3
 */
public class MT707Validator extends AbsMTValidator {

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

    @Override
    public void bussinessValidator() {
        //   MtResult mtResult = getMtResult();
        MT707 mt707 = (MT707)this.getAbstractMT();
        List<Tag> tags = this.getAbstractMT().getSwiftMessage().getBlock4().getTags();
        int count = 8;
        for (Tag tag : tags) {
            if(tag.getName().contains("50")){
                count++;
            }
            if(tag.getName().contains("52")){
                count++;
            }
        }
        if(count==tags.size()){
            mtResult.addDescription(Language.getLanguage("MT707_C1","【MT707】"));
        }if (!Objects.isNull(mt707.getField32B()) && !Objects.isNull(mt707.getField33B())){
            mtResult.addDescription(Language.getLanguage("MT707_C2","【MT707】"));
        }if (Objects.isNull(mt707.getField32B()) && Objects.isNull(mt707.getField33B())){
            mtResult.addDescription(Language.getLanguage("MT707_C2","【MT707】"));
        }if (!(!Objects.isNull(mt707.getField50B()) || (!Objects.isNull(mt707.getField52A()) || !Objects.isNull(mt707.getField52D())))){
            mtResult.addDescription(Language.getLanguage("MT707_C3","【MT707】"));
        }if (!Objects.isNull(mt707.getField44C()) && !Objects.isNull(mt707.getField44D())){
            mtResult.addDescription(Language.getLanguage("MT707_C4","【MT707】"));
        }
        // return  mtResult;
    }

}
