feature: added code refactoring changes for 2378 (#2379)

* fix:added code refactoring changes for 2378

* fix:added code refactoring changes for 2378

* build fix for 2378

* fix: updated pom.xml files for 2378 issue

* fix:build fix for 2378 issue

Co-authored-by: aparna <aparna@aparnas-MacBook-Air.local>
This commit is contained in:
Aparna
2022-12-10 20:25:37 +05:30
committed by GitHub
parent 6693527485
commit 147e2e681a
32 changed files with 202 additions and 134 deletions
@@ -24,9 +24,7 @@
*/
package com.iluwatar.leaderelection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Abstract class of all the message manager classes.
@@ -56,13 +54,13 @@ public abstract class AbstractMessageManager implements MessageManager {
.stream()
.filter((i) -> i > currentId && instanceMap.get(i).isAlive())
.sorted()
.collect(Collectors.toList());
.toList();
if (candidateList.isEmpty()) {
var index = instanceMap.keySet()
.stream()
.filter((i) -> instanceMap.get(i).isAlive())
.sorted()
.collect(Collectors.toList())
.toList()
.get(0);
result = instanceMap.get(index);
} else {