diff options
author | Martin Polden <mpolden@mpolden.no> | 2022-08-23 10:53:21 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2022-08-23 12:15:21 +0200 |
commit | fd1da43cbf6a1df0e98ed3f4a91c5566682e1c7a (patch) | |
tree | 531ed54d516000f0cdbbc9442c23f177fe90f233 /config-provisioning | |
parent | b3342e4388abe12660d60e0f3e934c03f1a322b8 (diff) |
Use requireZone
Diffstat (limited to 'config-provisioning')
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/Environment.java | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/Environment.java b/config-provisioning/src/main/java/com/yahoo/config/provision/Environment.java index 5ce43f6f2d7..2d3d5e062f7 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/Environment.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/Environment.java @@ -47,26 +47,25 @@ public enum Environment { /** Returns the environment name from the string value returned by value() */ public static Environment from(String value) { - switch(value) { - case "prod" : return prod; - case "staging" : return staging; - case "test" : return test; - case "dev" : return dev; - case "perf" : return perf; - default : throw new IllegalStateException("'" + value + "' is not a valid environment identifier"); - } + return switch (value) { + case "prod" -> prod; + case "staging" -> staging; + case "test" -> test; + case "dev" -> dev; + case "perf" -> perf; + default -> throw new IllegalArgumentException("'" + value + "' is not a valid environment identifier"); + }; } /** Returns a name of this which is used in external API's and stored in persistent stores */ public String value() { - switch(this) { - case prod : return "prod"; - case staging : return "staging"; - case test : return "test"; - case dev : return "dev"; - case perf : return "perf"; - default : throw new IllegalStateException(); - } + return switch (this) { + case prod -> "prod"; + case staging -> "staging"; + case test -> "test"; + case dev -> "dev"; + case perf -> "perf"; + }; } } |