From 359458bc3a10c3969eaf62263fb6211f7bd86c13 Mon Sep 17 00:00:00 2001 From: "kris.jinka" Date: Fri, 16 Nov 2018 20:16:14 +0900 Subject: Modify decoder to use param obj Modify decoder to use param object for sonar issue fix Issue-ID: POLICY-1251 Change-Id: Iae68ba276f02be51058037b56d901a131b25838e Signed-off-by: kris.jinka --- .../controller/internal/MavenDroolsController.java | 14 ++++-- .../drools/protocol/coders/EventProtocolCoder.java | 53 ++++++++++------------ 2 files changed, 32 insertions(+), 35 deletions(-) (limited to 'policy-management/src') diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java index ef20b84d..c707c8fc 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java +++ b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java @@ -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()) diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java index b9cb568c..1afd81a3 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java +++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java @@ -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 -- cgit 1.2.3-korg