aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorgjoranv <gjoranv@gmail.com>2023-11-02 13:32:56 +0100
committergjoranv <gjoranv@gmail.com>2023-11-02 13:32:56 +0100
commitea41233fdafa0a577e08dd8ebece5e7db233592f (patch)
treeb5790a73db188986c6f982b12c9e29061f48f877 /controller-api
parente64583fa0b618da67189152c10310293221dd8bc (diff)
Use 'value' when getting an enum object from a String.
- Ensures that the correct value is returned even if the name and value does not match.
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/BillStatus.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/BillStatus.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/BillStatus.java
index 00aa43cce5d..17698aff6f4 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/BillStatus.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/BillStatus.java
@@ -1,5 +1,7 @@
package com.yahoo.vespa.hosted.controller.api.integration.billing;
+import java.util.Arrays;
+
/**
* @author gjoranv
*/
@@ -34,7 +36,11 @@ public enum BillStatus {
public static BillStatus from(String status) {
if (LEGACY_ISSUED.equals(status) || LEGACY_EXPORTED.equals(status)) return OPEN;
if (LEGACY_CANCELED.equals(status)) return VOID;
- return Enum.valueOf(BillStatus.class, status.toUpperCase());
+
+ return Arrays.stream(values())
+ .filter(s -> s.value.equals(status))
+ .findFirst()
+ .orElseThrow(() -> new IllegalArgumentException("Unknown bill status: " + status));
}
}