package com.brilliance.isc.common.lgbdet.vo;

import com.brilliance.isc.bo.Cbb;
import com.brilliance.isc.common.vo.AbstractCommonVo;
import com.brilliance.isc.common.vo.BizInfoVo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.brilliance.mda.runtime.mda.Constants.NULLSTR;

@Getter
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public class LgbdetVo extends AbstractCommonVo {

    //业务信息
    private BizInfoVo rec;

    //金额信息
    private Map<String, Cbb> cbsMap;

    private List<LgbdetRegisterVo> lgbdetRegisterList;

    //Error Status
    private  String errsta = NULLSTR;
    //Error Message
    private  String errmsg = NULLSTR;
    //Old info read
    private  String oldredflg = NULLSTR;

    private List<LgbdetgVo> lgbdetg;

    private List<LgbismVo> lgbism;

    public void addLgbdetRegister(LgbdetRegisterVo lgbdetRegisterVo) {
        if (lgbdetRegisterList == null) {
            lgbdetRegisterList = new ArrayList<>();
        }
        lgbdetRegisterList.add(lgbdetRegisterVo);
    }

    public void addLgbdetg(LgbdetgVo lgbdetgVo) {
        if (lgbdetg == null) {
            lgbdetg = new ArrayList<>();
        }
        lgbdetg.add(lgbdetgVo);
    }

    public void addLgbism(LgbismVo lgbismVo) {
        if (lgbism == null) {
            lgbism = new ArrayList<>();
        }
        lgbism.add(lgbismVo);
    }

    @Override
    public void reset() {
        if (rec == null) {
            rec = new BizInfoVo();
        }
        rec.reset();
        if (cbsMap == null) {
            cbsMap = new HashMap<>();
        }
        if (lgbdetg == null) {
            lgbdetg = new ArrayList<>();
        }
        lgbdetg.forEach(g -> g.reset());
        if (lgbism == null) {
            lgbism = new ArrayList<>();
        }
        lgbism.forEach(m -> m.reset());
        if (lgbdetRegisterList == null) {
            lgbdetRegisterList = new ArrayList<>();
        }
    }
}
