import com.google.common.util.concurrent.SettableFuture;
import com.google.common.util.concurrent.Uninterruptibles;
import java.util.AbstractMap.SimpleEntry;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
void resolveShardAdditions(final Set<DOMDataTreeIdentifier> additions) {
LOG.debug("{}: Resolving additions : {}", memberName, additions);
- final ArrayList<DOMDataTreeIdentifier> list = new ArrayList<>(additions);
// we need to register the shards from top to bottom, so we need to atleast make sure the ordering reflects that
- Collections.sort(list, (o1, o2) -> {
- if (o1.getRootIdentifier().getPathArguments().size() < o2.getRootIdentifier().getPathArguments().size()) {
- return -1;
- } else if (o1.getRootIdentifier().getPathArguments().size()
- == o2.getRootIdentifier().getPathArguments().size()) {
- return 0;
- } else {
- return 1;
- }
- });
- list.forEach(this::createShardFrontend);
+ additions
+ .stream()
+ .sorted(Comparator.comparingInt(o -> o.getRootIdentifier().getPathArguments().size()))
+ .forEachOrdered(this::createShardFrontend);
}
void resolveShardRemovals(final Set<DOMDataTreeIdentifier> removals) {