Ensure that all path spec sets are disjoint
@@ -4,6 +4,7 @@ package com.yahoo.vespa.hosted.controller.role;
import com.yahoo.restapi.Path;
import java.util.EnumSet;
+import java.util.LinkedHashSet;
import java.util.Optional;
import java.util.Set;
@@ -97,4 +98,19 @@ public enum PathGroup {
}).isPresent();
}
+ static {
+ // Ensure that all path spec sets are disjoint
+ for (PathGroup pg : PathGroup.all()) {
+ for (PathGroup pg2 : PathGroup.all()) {
+ if (pg == pg2) continue;
+ Set<String> overlapping = new LinkedHashSet<>(pg.pathSpecs);
+ overlapping.retainAll(pg2.pathSpecs);
+ if (!overlapping.isEmpty()) {
+ throw new AssertionError("The following path specs overlap in " + pg + " and " + pg2 +
+ ": " + overlapping);
+ }
+ }
+ }
+ }
+
}
