jyothsnakonisa commented on code in PR #193:
URL: https://github.com/apache/cassandra-sidecar/pull/193#discussion_r1978362250


##########
server/src/main/java/org/apache/cassandra/sidecar/routes/cdc/Service.java:
##########
@@ -26,9 +29,27 @@ public enum Service
     CDC("cdc");
 
     public final String serviceName;
+    private static final Map<String, Service> LOOKUP = new HashMap<>();
+
+    static
+    {
+        for (Service service : Service.values())
+        {
+            LOOKUP.put(service.serviceName, service);
+        }
+    }
 
     Service(final String serviceName)
     {
         this.serviceName = serviceName;
     }
+
+    public static Service withName(String serviceName)
+    {
+        if (LOOKUP.containsKey(serviceName))
+        {
+            return LOOKUP.get(serviceName);
+        }
+        throw new RuntimeException("Invalid service name " + serviceName);
+    }

Review Comment:
   Enum.valueOf() is case sensitive, so when service name is lowercase 
valueOf() throws exception



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to