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


##########
server/src/main/java/org/apache/cassandra/sidecar/db/ConfigAccessorFactory.java:
##########
@@ -25,29 +27,22 @@
  */
 public class ConfigAccessorFactory
 {
-    private final KafkaConfigAccessor kafkaConfigAccessor;
-    private final CdcConfigAccessor cdcConfigAccessor;
+    private final Map<Service, ConfigAccessor> configAccessors = new 
HashMap<>();
 
     @Inject
     public ConfigAccessorFactory(KafkaConfigAccessor kafkaConfigAccessor,
                                  CdcConfigAccessor cdcConfigAccessor)
     {
-        this.kafkaConfigAccessor = kafkaConfigAccessor;
-        this.cdcConfigAccessor = cdcConfigAccessor;
+        configAccessors.put(Service.KAFKA, kafkaConfigAccessor);
+        configAccessors.put(Service.CDC, cdcConfigAccessor);
     }
 
-    public ConfigAccessor getConfigAccessor(final String service)
+    public ConfigAccessor getConfigAccessor(final Service service)
     {
-        if (service.equals(Service.KAFKA.serviceName))
+        if (configAccessors.containsKey(service))
         {
-            return kafkaConfigAccessor;
+            return configAccessors.get(service);
         }
-
-        if (service.equals(Service.CDC.serviceName))
-        {
-            return cdcConfigAccessor;
-        }
-
         throw new RuntimeException("Couldn't find a db accessor for service " 
+ service);
     }

Review Comment:
   Is there any reason to not to do containsKey call? is this to avoid calling 
`get()` & `containsKey` twice? I feel that checking containsKey is cleaner than 
making a null check.



-- 
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