Java 8 stream 条件匹配

少废话,直接上代码:

    public SelectVo findOneByName(List selectVoList , String name){
        List selectVos = selectVoList.stream().filter(x -> name.equals(x.getName())).collect(Collectors.toList());
        if(ToolsUtil.isEmpty(selectVos)){
            return null;
        }else {
            return selectVos.get(0);
        }
    }

你可能感兴趣的:(Java,java,开发语言,jdk8)