zoukankan      html  css  js  c++  java
  • Java8中List的removeif()函数的使用示例

    代码:

    import java.util.List;
    import java.util.function.Predicate;
    
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.bind.annotation.RestController;
    
    import com.anbank.eva.po.RptEbankMerchantDetail;
    import com.anbank.eva.service.RptEbankMerchantDetailService;
    
    @RestController
    @RequestMapping("/RPT_EBANK_MERCHANT_DETAIL")
    public class RptEbankMerchantDetailController {
    
    	@Autowired
        private RptEbankMerchantDetailService rptEbankMerchantDetailService;
    	
        @RequestMapping("/all")
        public List<RptEbankMerchantDetail> getAllRptEbankMerchantDetails() {
            List<RptEbankMerchantDetail> list = this.rptEbankMerchantDetailService.getAllRptEbankMerchantDetails();
            return list;
        }
        
        @RequestMapping("/result")
        public List<RptEbankMerchantDetail> getRptEbankMerchantDetails(@RequestParam(value="orgId", required=false)  String orgId,
    															    		@RequestParam(value="startDate", required=false) String startDate,
    																	    @RequestParam(value="endDate", required=false) String endDate,
    																	    @RequestParam(value="merId", required=false) String merId
        										) {
        	List<RptEbankMerchantDetail> list = this.rptEbankMerchantDetailService.getAllRptEbankMerchantDetails();
        	Predicate<RptEbankMerchantDetail> predicate = (ele) -> {
        		if (orgId != null && orgId.equals(ele.getORG_CODE()) == false)
        			return true;
    			if (startDate != null && startDate.compareTo(ele.getCREATE_DT()) > 0)
    				return true;
    			if (endDate != null && endDate.compareTo(ele.getCREATE_DT()) < 0)
    				return true;
    			if (merId != null && merId.equals(ele.getMER_ID()) == false)
    				return true;
    			return false;
        	};
        	list.removeIf(predicate);
        	return list;
        }
    }
    
  • 相关阅读:
    用感知机(Perceptron)实现逻辑AND功能的Python3代码
    xpadder教程:自定义设置游戏手柄的图片
    用Python实现小说中的汉字频率统计
    天猫精灵X1智能音箱使用感想
    一道常被人轻视的前端JS面试题
    jQueryNotes仿QQ空间添加标记
    JQ对象到底是什么
    正则匹配规则
    自定义右键菜单
    IIS处理并发请求时出现的问题及解决
  • 原文地址:https://www.cnblogs.com/zifeiy/p/9249092.html
Copyright © 2011-2022 走看看