aboutsummaryrefslogtreecommitdiffstats
path: root/config-model-api/src/main/java/com/yahoo/config/application/api/Notifications.java
diff options
context:
space:
mode:
Diffstat (limited to 'config-model-api/src/main/java/com/yahoo/config/application/api/Notifications.java')
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/application/api/Notifications.java29
1 files changed, 14 insertions, 15 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/Notifications.java b/config-model-api/src/main/java/com/yahoo/config/application/api/Notifications.java
index 370dfbff2b8..ac8900ab67b 100644
--- a/config-model-api/src/main/java/com/yahoo/config/application/api/Notifications.java
+++ b/config-model-api/src/main/java/com/yahoo/config/application/api/Notifications.java
@@ -7,10 +7,9 @@ import com.google.common.collect.ImmutableSet;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
-import static java.util.Collections.emptyList;
-
/**
* Configuration of notifications for deployment jobs.
*
@@ -59,7 +58,7 @@ public class Notifications {
/** Returns all email addresses to notify for the given condition. */
public Set<String> emailAddressesFor(When when) {
ImmutableSet.Builder<String> addresses = ImmutableSet.builder();
- addresses.addAll(emailAddresses.getOrDefault(when, emptyList()));
+ addresses.addAll(emailAddresses.getOrDefault(when, List.of()));
for (When include : when.includes)
addresses.addAll(emailAddressesFor(include));
return addresses.build();
@@ -68,7 +67,7 @@ public class Notifications {
/** Returns all roles for which email notification is to be sent for the given condition. */
public Set<Role> emailRolesFor(When when) {
ImmutableSet.Builder<Role> roles = ImmutableSet.builder();
- roles.addAll(emailRoles.getOrDefault(when, emptyList()));
+ roles.addAll(emailRoles.getOrDefault(when, List.of()));
for (When include : when.includes)
roles.addAll(emailRolesFor(include));
return roles.build();
@@ -81,17 +80,17 @@ public class Notifications {
author;
public static String toValue(Role role) {
- switch (role) {
- case author: return "author";
- default: throw new IllegalArgumentException("Unexpected constant '" + role.name() + "'.");
+ if (Objects.requireNonNull(role) == Role.author) {
+ return "author";
}
+ throw new IllegalArgumentException("Unexpected constant '" + role.name() + "'.");
}
public static Role fromValue(String value) {
- switch (value) {
- case "author": return author;
- default: throw new IllegalArgumentException("Unknown value '" + value + "'.");
+ if (value.equals("author")) {
+ return author;
}
+ throw new IllegalArgumentException("Unknown value '" + value + "'.");
}
}
@@ -112,11 +111,11 @@ public class Notifications {
}
public static String toValue(When when) {
- switch (when) {
- case failing: return "failing";
- case failingCommit: return "failing-commit";
- default: throw new IllegalArgumentException("Unexpected constant '" + when.name() + "'.");
- }
+ return switch (when) {
+ case failing -> "failing";
+ case failingCommit -> "failing-commit";
+ default -> throw new IllegalArgumentException("Unexpected constant '" + when.name() + "'.");
+ };
}
public static When fromValue(String value) {