Modify decoder to use param obj 98/72898/1
authorkris.jinka <kris.jinka@samsung.com>
Fri, 16 Nov 2018 11:16:14 +0000 (20:16 +0900)
committerkris.jinka <kris.jinka@samsung.com>
Fri, 16 Nov 2018 11:16:27 +0000 (20:16 +0900)
Modify decoder to use param object for sonar issue fix

Issue-ID: POLICY-1251
Change-Id: Iae68ba276f02be51058037b56d901a131b25838e
Signed-off-by: kris.jinka <kris.jinka@samsung.com>
policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java
policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java

index ef20b84..c707c8f 100644 (file)
@@ -305,11 +305,15 @@ public class MavenDroolsController implements DroolsController {
                 }
 
                 if (decoder) {
-                    EventProtocolCoder.manager.addDecoder(this.getGroupId(), this.getArtifactId(), 
-                            topic, potentialCodedClass, protocolFilter,
-                            customGsonCoder,
-                            customJacksonCoder,
-                            this.policyContainer.getClassLoader().hashCode());
+                    EventProtocolCoder.manager.addDecoder(EventProtocolParams.builder()
+                            .groupId(this.getGroupId())
+                            .artifactId(this.getArtifactId())
+                            .topic(topic)
+                            .eventClass(potentialCodedClass)
+                            .protocolFilter(protocolFilter)
+                            .customGsonCoder(customGsonCoder)
+                            .customJacksonCoder(customJacksonCoder)
+                            .modelClassLoaderHash(this.policyContainer.getClassLoader().hashCode()));
                 } else {
                     EventProtocolCoder.manager.addEncoder(
                             EventProtocolParams.builder().groupId(this.getGroupId())
index b9cb568..1afd81a 100644 (file)
@@ -130,23 +130,11 @@ public interface EventProtocolCoder {
 
     /**
      * Adds a Decoder class to decode the protocol over this topic.
-     *  
-     * @param groupId of the controller
-     * @param artifactId of the controller
-     * @param topic the topic 
-     * @param eventClass the event class
-     * @param protocolFilter filters to selectively choose a particular decoder
-     *     when there are multiples
-     * 
+     *
+     * @param eventProtocolParams parameter object for event protocol
      * @throw IllegalArgumentException if an invalid parameter is passed
      */
-    public void addDecoder(String groupId, String artifactId, 
-            String topic, 
-            String eventClass, 
-            JsonProtocolFilter protocolFilter, 
-            CustomGsonCoder customGsonCoder,
-            CustomJacksonCoder customJacksonCoder,
-            int modelClassLoaderHash);
+    public void addDecoder(EventProtocolParams eventProtocolParams);
 
     /**
      * removes all decoders associated with the controller id.
@@ -280,9 +268,9 @@ public interface EventProtocolCoder {
 
     /**
      * Adds a Encoder class to encode the protocol over this topic.
-     *  
      *
-     * @param eventProtocolParams@throw IllegalArgumentException if an invalid parameter is passed
+     * @param eventProtocolParams parameter object for event protocol
+     * @throw IllegalArgumentException if an invalid parameter is passed
      */
     public void addEncoder(EventProtocolParams eventProtocolParams);
 
@@ -401,18 +389,23 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
      * {@inheritDoc}.
      */
     @Override
-    public void addDecoder(String groupId, String artifactId, String topic, 
-            String eventClass, 
-            JsonProtocolFilter protocolFilter,
-            CustomGsonCoder customGsonCoder,
-            CustomJacksonCoder customJacksonCoder,
-            int modelClassLoaderHash) {
-        logger.info("{}: add-decoder {}:{}:{}:{}:{}:{}:{}:{}", this, 
-                groupId, artifactId, topic, eventClass,
-                protocolFilter, customGsonCoder, customJacksonCoder,
-                modelClassLoaderHash);
-        this.decoders.add(groupId, artifactId, topic, eventClass, protocolFilter, 
-                customGsonCoder, customJacksonCoder, modelClassLoaderHash);
+    public void addDecoder(EventProtocolParams eventProtocolParams) {
+        logger.info("{}: add-decoder {}:{}:{}:{}:{}:{}:{}:{}", this,
+                eventProtocolParams.getGroupId(),
+                eventProtocolParams.getArtifactId(),
+                eventProtocolParams.getTopic(),
+                eventProtocolParams.getEventClass(),
+                eventProtocolParams.getProtocolFilter(),
+                eventProtocolParams.getCustomGsonCoder(),
+                eventProtocolParams.getCustomJacksonCoder(),
+                eventProtocolParams.getModelClassLoaderHash());
+        this.decoders.add(eventProtocolParams.getGroupId(), eventProtocolParams.getArtifactId(),
+                eventProtocolParams.getTopic(),
+                eventProtocolParams.getEventClass(),
+                eventProtocolParams.getProtocolFilter(),
+                eventProtocolParams.getCustomGsonCoder(),
+                eventProtocolParams.getCustomJacksonCoder(),
+                eventProtocolParams.getModelClassLoaderHash());
     }
 
     /**
@@ -796,7 +789,7 @@ abstract class GenericEventProtocolCoder  {
     /**
      * produces key for indexing toolset entries.
      * 
-     * @param group group id
+     * @param groupId group id
      * @param artifactId artifact id
      * @param topic topic
      * @return index key