problem description
 this code is often used in my project. I want to package it into a method to reduce the amount of code, but I failed to do it because I am a rookie. Thank you in advance. 
 purpose: to change the classes hardwareServices and Hardware into formal parameters 
the environmental background of the problems and what methods you have tried
 Java version: 1.8 
 try to use generics, but end up reporting an error because you want to call the method of the class 
related codes
 / / Please paste the code text below (do not replace the code with pictures) 
 private HardwareServices hardwareServices; 
 List < Hardware > hardwareList = hardwareServices.selectList (wrapper); 
        if(hardwareList.size() > 0){
            for (Hardware i: hardwareList) {
                if(i.getName().equals(hardware.getName())){
                    if(i.getIsDelete() == 1){
                        wrapper.eq("is_delete", 1).eq("id", i.getId());
                        hardware.setIsDelete(0);
                        hardware.setChangeMan(selectUser.getName());
                        hardware.setUpdateTime(nowData);
                        hardwareServices.update(hardware, wrapper);
                        result.setValue(hardware);
                    }else{
                        result.setMsg("");
                        result.setCode(-1);
                    }
                    return result;
                }
            }
        }
        
 here is the code from another place: 
 EntityWrapper < ProductProcess > wrapper = new EntityWrapper < ProductProcess > (); 
 List < ProductProcess > hardwareList=productProcessServices.selectList (wrapper); 
        if(hardwareList.size() > 0){
            for (ProductProcess i: hardwareList) {
                if(i.getName().equals(productProcess.getName())){
                    if(i.getIsDelete() == 1){
                        wrapper.eq("is_delete", 1).eq("id", i.getId());
                        productProcess.setIsDelete(0);
                        productProcess.setChangeMan(selectUser.getName());
                        productProcess.setUpdateTime(nowData);
                        productProcessServices.update(productProcess, wrapper);
                        result.setValue(productProcess);
                    }else{
                        result.setMsg("");
                        result.setCode(-1);
                    }
                    return result;
                }
            }
        }
						