Skip to content

Commit

Permalink
Verify that there can't be two handlers with same name (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper committed May 22, 2024
1 parent 2b5d8e4 commit 026e10f
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class Service {

Expand Down Expand Up @@ -144,6 +145,11 @@ public Service validateAndBuild() {
}
}

if (handlers.size()
!= handlers.stream().map(Handler::getName).collect(Collectors.toSet()).size()) {
throw new IllegalArgumentException("Cannot have two handlers with the same name");
}

return new Service(
Objects.requireNonNull(targetPkg),
Objects.requireNonNull(targetFqcn),
Expand Down

0 comments on commit 026e10f

Please sign in to comment.