Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
For loop 带有Set<;的Convert子句;地图<;字符串,对象>&燃气轮机;对forEach条款_For Loop_Foreach_Java 8 - Fatal编程技术网

For loop 带有Set<;的Convert子句;地图<;字符串,对象>&燃气轮机;对forEach条款

For loop 带有Set<;的Convert子句;地图<;字符串,对象>&燃气轮机;对forEach条款,for-loop,foreach,java-8,For Loop,Foreach,Java 8,我有以下方法: protected Set<Map<String, Object>> joinQueryResults(Set<Map<String, Object>> resultEmpty, Set<Map<String, Object>> resultWithValues){ for(Map<String, Object> mapEmpty: resultEmpty){

我有以下方法:

protected Set<Map<String, Object>> joinQueryResults(Set<Map<String, Object>> resultEmpty, Set<Map<String, Object>> resultWithValues){
    for(Map<String, Object> mapEmpty: resultEmpty){         
        for(Map<String, Object> mapValue: resultWithValues){
            if (mapValue.get("name").equals(mapEmpty.get("name"))){
                mapEmpty.replace("totfailed", mapValue.get("totfailed"));
                mapEmpty.replace("totsuccess", mapValue.get("totsuccess"));
                break;
            }       
        }   
    }       
    return resultEmpty; 
}
受保护的Set-joinQueryResults(Set-Resulty,Set-ResultWithValue){
对于(Map mapepty:resulty){
用于(映射映射值:resultWithValues){
if(mapValue.get(“name”).equals(mapEmpty.get(“name”)){
mapEmpty.replace(“totfailed”,mapValue.get(“totfailed”);
mapEmpty.replace(“totsuccess”,mapValue.get(“totsuccess”);
打破
}       
}   
}       
回报诱人;
}

如何将其转换为forEach子句?有可能吗?

不赞成更新流中的共享可变变量。这应该可以做到

resultEmpty.stream().forEach(empty -> {
  resultWithValues.stream()
      .filter(
          withValues -> withValues.get("name").equals(empty.get("name")))
      .findFirst().ifPresent(withValues -> {
        empty.replace("totsuccess", withValues.get("totsuccess"));
        empty.replace("totfailed", withValues.get("totfailed"));
      });
});