diff options
Diffstat (limited to 'config-model-api/src/main/java/com/yahoo')
-rw-r--r-- | config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java | 2 | ||||
-rw-r--r-- | config-model-api/src/main/java/com/yahoo/config/application/api/Notifications.java | 29 |
2 files changed, 15 insertions, 16 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java b/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java index 16cd7bf7e88..4308e0c2a0e 100644 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java +++ b/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java @@ -386,7 +386,7 @@ public class DeploymentSpec { public abstract boolean concerns(Environment environment, Optional<RegionName> region); /** Returns the zones deployed to in this step. */ - public List<DeclaredZone> zones() { return Collections.emptyList(); } + public List<DeclaredZone> zones() { return List.of(); } /** The delay introduced by this step (beyond the time it takes to execute the step). */ public Duration delay() { return Duration.ZERO; } 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) { |