Skip to content

Commit

Permalink
Rewrite childDepth() to make use of OptionalInt
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-ronge committed Jan 30, 2024
1 parent 685396c commit b7ebb5f
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -552,11 +553,11 @@ private void executeActionForErroreousProcess(int action) throws IOException {
* @return number of levels of children below
*/
int childDepth() {
if (children.isEmpty()) {
OptionalInt childrenMaxDepth = children.parallelStream().mapToInt(ImportingProcess::childDepth).max();
if(childrenMaxDepth.isEmpty()) {
return 0;
} else {
int childrenMaxDepth = children.parallelStream().mapToInt(ImportingProcess::childDepth).max().getAsInt();
return childrenMaxDepth + 1;
return childrenMaxDepth.getAsInt() + 1;
}
}

Expand Down

0 comments on commit b7ebb5f

Please sign in to comment.