Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump edu.hm.hafner:codingstyle-pom from 4.11.0 to 4.12.0 #112

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>edu.hm.hafner</groupId>
<artifactId>codingstyle-pom</artifactId>
<version>4.11.0</version>
<version>4.12.0</version>
<relativePath />
</parent>

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/edu/hm/hafner/coverage/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -672,26 +672,25 @@ private String createTargetClassName(final ClassNode testClassNode) {
*
* @return a new tree with the merged {@link Node nodes}
*/
public static Node merge(final List<? extends Node> nodes) {
public static Node merge(final List<Node> nodes) {
if (nodes.isEmpty()) {
throw new IllegalArgumentException("Cannot merge an empty list of nodes");
}
if (nodes.size() == 1) {
return nodes.get(0); // No merge required
}

Map<ImmutablePair<String, Metric>, ? extends List<? extends Node>> grouped = nodes.stream()
Map<ImmutablePair<String, Metric>, ? extends List<Node>> grouped = nodes.stream()
.collect(Collectors.groupingBy(n -> new ImmutablePair<>(n.getName(), n.getMetric())));

if (grouped.size() == 1) {
return nodes.stream()
.map(t -> (Node) t)
.reduce(Node::merge)
.orElseThrow(() -> new NoSuchElementException("No node found"));
}

var container = new ContainerNode("Container"); // non-compatible nodes will be added to a new container node
for (List<? extends Node> matching : grouped.values()) {
for (List<Node> matching : grouped.values()) {
container.addChild(merge(matching));
}
return container;
Expand Down
Loading