package com.yihu.hos.standard.match.matchModel;

import com.yihu.hos.standard.model.adapter.AdapterDictEntryModel;
import com.yihu.hos.standard.util.GetChineseFirst;

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

/**
 * Created by Administrator on 2016/6/29.
 */
public class DictItemMatchVO {

   private Map<String, List<AdapterDictEntryModel>> codeAdapter = new HashMap<String, List<AdapterDictEntryModel>>();

    public Map<String, List<AdapterDictEntryModel>> getCodeAdapter() {
        return codeAdapter;
    }

    public void setCodeAdapter(Map<String, List<AdapterDictEntryModel>> codeAdapter) {
        this.codeAdapter = codeAdapter;
    }

    /**
     * 根据name的首字母分组
     * @param stdeAdapterDictitems
     * @return
     */
    public Map<String, List<AdapterDictEntryModel>> geNameGroup(List<AdapterDictEntryModel> stdeAdapterDictitems) {
        Map<String, List<AdapterDictEntryModel>> returnMap = new HashMap<String, List<AdapterDictEntryModel>>();
        for (AdapterDictEntryModel stdeAdapterDictitem : stdeAdapterDictitems) {
            String firstCode= GetChineseFirst.cn2py(stdeAdapterDictitem.getStdEntryValue());
            List<AdapterDictEntryModel> temp=returnMap.get(firstCode);
            if(temp!=null){
                temp.add(stdeAdapterDictitem);
            }else{
                temp=new ArrayList<AdapterDictEntryModel>();
                temp.add(stdeAdapterDictitem);
            }
            returnMap.put(firstCode,temp);
        }
        return returnMap;
    }
}
