@Override
    public void doSearch(String string, List<ControlPerson> controlPersonList, List<ControlCar> controlCarsList) {
        List<ControlPerson> personSearchResult = new ArrayList<>();
        List<ControlCar> carSearchResult = new ArrayList<>();

        Pattern pattern = Pattern.compile(string);

        for(int i = 0; i<controlPersonList.size(); i++){
            Matcher matcher1 = pattern.matcher(controlPersonList.get(i).getId());
            Matcher matcher2 = pattern.matcher(controlPersonList.get(i).getName());
            if(matcher1.matches() || matcher2.matches()){
                personSearchResult.add(controlPersonList.get(i));
            }
        }
        for(int i = 0; i<controlCarsList.size(); i++){
            Matcher matcher3 = pattern.matcher(controlCarsList.get(i).getPlate());
            if(matcher3.matches()){
                carSearchResult.add(controlCarsList.get(i));
            }
        }
        iFilterControlDataView.initPersonList(personSearchResult);
        iFilterControlDataView.initCarList(carSearchResult);
    }

 

收藏 打印