码迷,mamicode.com
首页 > 编程语言 > 详细

Java8中List的removeif()函数的使用示例

时间:2018-07-01 00:24:05      阅读:1036      评论:0      收藏:0      [点我收藏+]

标签:factory   tde   bin   red   compareto   ota   java8   AC   util   

代码:

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;
    }
}

Java8中List的removeif()函数的使用示例

标签:factory   tde   bin   red   compareto   ota   java8   AC   util   

原文地址:https://www.cnblogs.com/zifeiy/p/9249092.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!