aboutsummaryrefslogtreecommitdiffstats
path: root/policy-management/src/main/java/org/onap/policy/drools/protocol
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2018-02-19 16:56:06 -0500
committerJim Hahn <jrh3@att.com>2018-02-20 09:59:15 -0500
commita45f8909871dc1ddb75845f067a602951afc8d11 (patch)
treefa72aff7ceede971d4e6922f62a503a8ee8924d5 /policy-management/src/main/java/org/onap/policy/drools/protocol
parent1708e9a45cb88571613c10b68d392811b2b3f0f4 (diff)
Sonar fixes to drools-pdp
Fixed most of the instances of the following sonar issues: Moved array designator Used diamond operator Changed System.out/err to use a logger Changed several Thread.sleep() in test code to a single sleep() Useless assignments Replaced comparison with "" to string.isEmpty() Merged if's Replaced ArrayList with List in method returns Reordered type modifiers Reordered constructor methods Defined constants for literals, or replaced them with method calls Removed "throws Xxx" for subclasses of RuntimeException Combined identical "catch" blocks Re-interrupted the current thread after catching an InterruptedException Removed tests against the literal "false" Fix indentation of new makeTopicOperError() method. Fix exception variable name in new methods, logNoUebEncoder() and logNoDmaapEncoder(). Change-Id: Iddae5210553662f733b67333b372dec8c3fe2c94 Issue-ID: POLICY-336 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-management/src/main/java/org/onap/policy/drools/protocol')
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java216
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java66
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java92
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java14
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java8
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java8
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java14
7 files changed, 187 insertions, 231 deletions
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 54466775..d0008f08 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
@@ -1,4 +1,4 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
@@ -39,6 +39,11 @@ import org.slf4j.LoggerFactory;
*/
public interface EventProtocolCoder {
+ /**
+ * singleton reference to the global event protocol coder
+ */
+ public static EventProtocolCoder manager = new MultiplexorEventProtocolCoder();
+
public static class CoderFilters {
/**
@@ -133,8 +138,7 @@ public interface EventProtocolCoder {
JsonProtocolFilter protocolFilter,
CustomGsonCoder customGsonCoder,
CustomJacksonCoder customJacksonCoder,
- int modelClassLoaderHash)
- throws IllegalArgumentException;
+ int modelClassLoaderHash);
/**
* removes all decoders associated with the controller id
@@ -144,7 +148,7 @@ public interface EventProtocolCoder {
*
* @throws IllegalArgumentException if invalid arguments have been provided
*/
- void removeEncoders(String groupId, String artifactId, String topic) throws IllegalArgumentException;
+ void removeEncoders(String groupId, String artifactId, String topic);
/**
* removes decoders associated with the controller id and topic
@@ -154,7 +158,7 @@ public interface EventProtocolCoder {
*
* @throws IllegalArgumentException if invalid arguments have been provided
*/
- public void removeDecoders(String groupId, String artifactId, String topic) throws IllegalArgumentException;
+ public void removeDecoders(String groupId, String artifactId, String topic);
/**
* Given a controller id and a topic, it gives back its filters
@@ -167,8 +171,7 @@ public interface EventProtocolCoder {
*
* @throw IllegalArgumentException if an invalid parameter is passed
*/
- public List<CoderFilters> getDecoderFilters(String groupId, String artifactId, String topic)
- throws IllegalArgumentException;
+ public List<CoderFilters> getDecoderFilters(String groupId, String artifactId, String topic);
/**
@@ -182,8 +185,7 @@ public interface EventProtocolCoder {
*
* @throw IllegalArgumentException if an invalid parameter is passed
*/
- public ProtocolCoderToolset getDecoders(String groupId, String artifactId, String topic)
- throws IllegalArgumentException;
+ public ProtocolCoderToolset getDecoders(String groupId, String artifactId, String topic);
/**
* Given a controller id and a topic, it gives back all the decoding configurations
@@ -196,8 +198,7 @@ public interface EventProtocolCoder {
*
* @throw IllegalArgumentException if an invalid parameter is passed
*/
- public List<ProtocolCoderToolset> getDecoders(String groupId, String artifactId)
- throws IllegalArgumentException;
+ public List<ProtocolCoderToolset> getDecoders(String groupId, String artifactId);
/**
@@ -207,7 +208,7 @@ public interface EventProtocolCoder {
*
* @throws IllegalArgumentException if invalid arguments have been provided
*/
- public List<CoderFilters> getDecoderFilters(String groupId, String artifactId) throws IllegalArgumentException;
+ public List<CoderFilters> getDecoderFilters(String groupId, String artifactId);
/**
@@ -221,8 +222,7 @@ public interface EventProtocolCoder {
*
* @throw IllegalArgumentException if an invalid parameter is passed
*/
- public List<CoderFilters> getEncoderFilters(String groupId, String artifactId, String topic)
- throws IllegalArgumentException;
+ public List<CoderFilters> getEncoderFilters(String groupId, String artifactId, String topic);
/**
* gets all encoders associated with the group and artifact ids
@@ -231,7 +231,7 @@ public interface EventProtocolCoder {
*
* @throws IllegalArgumentException if invalid arguments have been provided
*/
- public List<CoderFilters> getEncoderFilters(String groupId, String artifactId) throws IllegalArgumentException;
+ public List<CoderFilters> getEncoderFilters(String groupId, String artifactId);
/**
* Given a controller id, a topic, and a classname, it gives back the classes that implements the decoding
@@ -245,8 +245,7 @@ public interface EventProtocolCoder {
*
* @throw IllegalArgumentException if an invalid parameter is passed
*/
- public CoderFilters getDecoderFilters(String groupId, String artifactId, String topic, String classname)
- throws IllegalArgumentException;
+ public CoderFilters getDecoderFilters(String groupId, String artifactId, String topic, String classname);
/**
* is there a decoder supported for the controller id and topic
@@ -275,8 +274,7 @@ public interface EventProtocolCoder {
JsonProtocolFilter protocolFilter,
CustomGsonCoder customGsonCoder,
CustomJacksonCoder customJacksonCoder,
- int modelClassLoaderHash)
- throws IllegalArgumentException;
+ int modelClassLoaderHash);
/**
* is there an encoder supported for the controller id and topic
@@ -298,8 +296,7 @@ public interface EventProtocolCoder {
* @return
* @throws IllegalArgumentException invalid arguments passed in
*/
- public CoderFilters getEncoderFilters(String groupId, String artifactId, String topic, String classname)
- throws IllegalArgumentException;
+ public CoderFilters getEncoderFilters(String groupId, String artifactId, String topic, String classname);
/**
* get encoder based on topic and encoded class
@@ -309,8 +306,7 @@ public interface EventProtocolCoder {
* @return
* @throws IllegalArgumentException invalid arguments passed in
*/
- public List<CoderFilters> getReverseEncoderFilters(String topic, String encodedClass)
- throws IllegalArgumentException;
+ public List<CoderFilters> getReverseEncoderFilters(String topic, String encodedClass);
/**
* gets the identifier of the creator of the encoder
@@ -320,8 +316,7 @@ public interface EventProtocolCoder {
* @return a drools controller
* @throws IllegalArgumentException invalid arguments passed in
*/
- public DroolsController getDroolsController(String topic, Object encodedClass)
- throws IllegalArgumentException;
+ public DroolsController getDroolsController(String topic, Object encodedClass);
/**
* gets the identifier of the creator of the encoder
@@ -331,8 +326,7 @@ public interface EventProtocolCoder {
* @return list of drools controllers
* @throws IllegalArgumentException invalid arguments passed in
*/
- public List<DroolsController> getDroolsControllers(String topic, Object encodedClass)
- throws IllegalArgumentException;
+ public List<DroolsController> getDroolsControllers(String topic, Object encodedClass);
/**
* decode topic's stringified event (json) to corresponding Event Object.
@@ -346,8 +340,7 @@ public interface EventProtocolCoder {
* @throws UnsupportedOperationException if the operation is not supported
* @throws IllegalStateException if the system is in an illegal state
*/
- public Object decode(String groupId, String artifactId, String topic, String json)
- throws IllegalArgumentException, UnsupportedOperationException, IllegalStateException;
+ public Object decode(String groupId, String artifactId, String topic, String json);
/**
* encodes topic's stringified event (json) to corresponding Event Object.
@@ -359,8 +352,7 @@ public interface EventProtocolCoder {
*
* @throws IllegalArgumentException invalid arguments passed in
*/
- public String encode(String groupId, String artifactId, String topic, Object event)
- throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException;
+ public String encode(String groupId, String artifactId, String topic, Object event);
/**
* encodes topic's stringified event (json) to corresponding Event Object.
@@ -371,8 +363,7 @@ public interface EventProtocolCoder {
* @throws IllegalArgumentException invalid arguments passed in
* @throws UnsupportedOperationException operation cannot be performed
*/
- public String encode(String topic, Object event)
- throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException;
+ public String encode(String topic, Object event);
/**
* encodes topic's stringified event (json) to corresponding Event Object.
@@ -384,13 +375,7 @@ public interface EventProtocolCoder {
* @throws IllegalArgumentException invalid arguments passed in
* @throws UnsupportedOperationException operation cannot be performed
*/
- public String encode(String topic, Object event, DroolsController droolsController)
- throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException;
-
- /**
- * singleton reference to the global event protocol coder
- */
- public static EventProtocolCoder manager = new MultiplexorEventProtocolCoder();
+ public String encode(String topic, Object event, DroolsController droolsController);
}
/**
@@ -423,8 +408,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
JsonProtocolFilter protocolFilter,
CustomGsonCoder customGsonCoder,
CustomJacksonCoder customJacksonCoder,
- int modelClassLoaderHash)
- throws IllegalArgumentException {
+ int modelClassLoaderHash) {
logger.info("{}: add-decoder {}:{}:{}:{}:{}:{}:{}:{}", this,
groupId, artifactId, topic, eventClass,
protocolFilter, customGsonCoder, customJacksonCoder,
@@ -442,8 +426,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
JsonProtocolFilter protocolFilter,
CustomGsonCoder customGsonCoder,
CustomJacksonCoder customJacksonCoder,
- int modelClassLoaderHash)
- throws IllegalArgumentException {
+ int modelClassLoaderHash) {
logger.info("{}: add-decoder {}:{}:{}:{}:{}:{}:{}:{}", this,
groupId, artifactId, topic, eventClass,
protocolFilter, customGsonCoder, customJacksonCoder,
@@ -456,8 +439,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public void removeDecoders(String groupId, String artifactId, String topic)
- throws IllegalArgumentException {
+ public void removeDecoders(String groupId, String artifactId, String topic) {
logger.info("{}: remove-decoder {}:{}:{}", this, groupId, artifactId, topic);
this.decoders.remove(groupId, artifactId, topic);
}
@@ -466,8 +448,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public void removeEncoders(String groupId, String artifactId, String topic)
- throws IllegalArgumentException {
+ public void removeEncoders(String groupId, String artifactId, String topic) {
logger.info("{}: remove-encoder {}:{}:{}", this, groupId, artifactId, topic);
this.encoders.remove(groupId, artifactId, topic);
}
@@ -492,8 +473,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public Object decode(String groupId, String artifactId, String topic, String json)
- throws IllegalArgumentException, UnsupportedOperationException, IllegalStateException {
+ public Object decode(String groupId, String artifactId, String topic, String json) {
logger.debug("{}: decode {}:{}:{}:{}", this, groupId, artifactId, topic, json);
return this.decoders.decode(groupId, artifactId, topic, json);
}
@@ -502,8 +482,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public String encode(String groupId, String artifactId, String topic, Object event)
- throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException {
+ public String encode(String groupId, String artifactId, String topic, Object event) {
logger.debug("{}: encode {}:{}:{}:{}", this, groupId, artifactId, topic, event);
return this.encoders.encode(groupId, artifactId, topic, event);
}
@@ -512,8 +491,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public String encode(String topic, Object event)
- throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException {
+ public String encode(String topic, Object event) {
logger.debug("{}: encode {}:{}", this, topic, event);
return this.encoders.encode(topic, event);
}
@@ -522,8 +500,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public String encode(String topic, Object event, DroolsController droolsController)
- throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException {
+ public String encode(String topic, Object event, DroolsController droolsController) {
logger.debug("{}: encode {}:{}:{}", this, topic, event, droolsController);
return this.encoders.encode(topic, event, droolsController);
}
@@ -532,8 +509,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public List<CoderFilters> getDecoderFilters(String groupId, String artifactId, String topic)
- throws IllegalArgumentException {
+ public List<CoderFilters> getDecoderFilters(String groupId, String artifactId, String topic) {
return this.decoders.getFilters(groupId, artifactId, topic);
}
@@ -541,8 +517,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public ProtocolCoderToolset getDecoders(String groupId, String artifactId, String topic)
- throws IllegalArgumentException {
+ public ProtocolCoderToolset getDecoders(String groupId, String artifactId, String topic) {
Pair<ProtocolCoderToolset,ProtocolCoderToolset> decoderToolsets = this.decoders.getCoders(groupId, artifactId, topic);
if (decoderToolsets == null)
throw new IllegalArgumentException("Decoders not found for " + groupId + ":" + artifactId + ":" + topic);
@@ -554,8 +529,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public List<CoderFilters> getEncoderFilters(String groupId, String artifactId, String topic)
- throws IllegalArgumentException {
+ public List<CoderFilters> getEncoderFilters(String groupId, String artifactId, String topic) {
return this.encoders.getFilters(groupId, artifactId, topic);
}
@@ -563,8 +537,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public CoderFilters getDecoderFilters(String groupId, String artifactId, String topic, String classname)
- throws IllegalArgumentException {
+ public CoderFilters getDecoderFilters(String groupId, String artifactId, String topic, String classname) {
return this.decoders.getFilters(groupId, artifactId, topic, classname);
}
@@ -572,8 +545,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public CoderFilters getEncoderFilters(String groupId, String artifactId, String topic, String classname)
- throws IllegalArgumentException {
+ public CoderFilters getEncoderFilters(String groupId, String artifactId, String topic, String classname) {
return this.encoders.getFilters(groupId, artifactId, topic, classname);
}
@@ -581,7 +553,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public List<CoderFilters> getReverseEncoderFilters(String topic, String encodedClass) throws IllegalArgumentException {
+ public List<CoderFilters> getReverseEncoderFilters(String topic, String encodedClass) {
return this.encoders.getReverseFilters(topic, encodedClass);
}
@@ -595,8 +567,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* @throws IllegalArgumentException if invalid input
*/
@Override
- public List<ProtocolCoderToolset> getDecoders(String groupId, String artifactId)
- throws IllegalArgumentException {
+ public List<ProtocolCoderToolset> getDecoders(String groupId, String artifactId) {
List<Pair<ProtocolCoderToolset,ProtocolCoderToolset>> decoderToolsets = this.decoders.getCoders(groupId, artifactId);
if (decoderToolsets == null)
@@ -614,7 +585,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public List<CoderFilters> getDecoderFilters(String groupId, String artifactId) throws IllegalArgumentException {
+ public List<CoderFilters> getDecoderFilters(String groupId, String artifactId) {
return this.decoders.getFilters(groupId, artifactId);
}
@@ -623,7 +594,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public List<CoderFilters> getEncoderFilters(String groupId, String artifactId) throws IllegalArgumentException {
+ public List<CoderFilters> getEncoderFilters(String groupId, String artifactId) {
return this.encoders.getFilters(groupId, artifactId);
}
@@ -631,7 +602,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public DroolsController getDroolsController(String topic, Object encodedClass) throws IllegalArgumentException {
+ public DroolsController getDroolsController(String topic, Object encodedClass) {
return this.encoders.getDroolsController(topic, encodedClass);
}
@@ -639,7 +610,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* {@inheritDoc}
*/
@Override
- public List<DroolsController> getDroolsControllers(String topic, Object encodedClass) throws IllegalArgumentException {
+ public List<DroolsController> getDroolsControllers(String topic, Object encodedClass) {
return this.encoders.getDroolsControllers(topic, encodedClass);
}
@@ -660,6 +631,16 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* class and best fitted json parsing tools.
*/
abstract class GenericEventProtocolCoder {
+ private static final String INVALID_ARTIFACT_ID_MSG = "Invalid artifact id";
+
+ private static final String INVALID_GROUP_ID_MSG = "Invalid group id";
+
+ private static final String INVALID_TOPIC_MSG = "Invalid Topic";
+
+ private static final String UNSUPPORTED_MSG = "Unsupported";
+
+ private static final String MISSING_CLASS = "class must be provided";
+
private static Logger logger = LoggerFactory.getLogger(GenericEventProtocolCoder.class);
/**
@@ -702,17 +683,16 @@ abstract class GenericEventProtocolCoder {
JsonProtocolFilter protocolFilter,
CustomGsonCoder customGsonCoder,
CustomJacksonCoder customJacksonCoder,
- int modelClassLoaderHash)
- throws IllegalArgumentException {
+ int modelClassLoaderHash) {
if (groupId == null || groupId.isEmpty()) {
- throw new IllegalArgumentException("Invalid group id");
+ throw new IllegalArgumentException(INVALID_GROUP_ID_MSG);
}
if (artifactId == null || artifactId.isEmpty())
- throw new IllegalArgumentException("Invalid artifact id");
+ throw new IllegalArgumentException(INVALID_ARTIFACT_ID_MSG);
if (topic == null || topic.isEmpty())
- throw new IllegalArgumentException("Invalid Topic");
+ throw new IllegalArgumentException(INVALID_TOPIC_MSG);
if (eventClass == null) {
throw new IllegalArgumentException("Invalid Event Class");
@@ -841,17 +821,16 @@ abstract class GenericEventProtocolCoder {
* @param topic topic
* @throws IllegalArgumentException if invalid input
*/
- public void remove(String groupId, String artifactId, String topic)
- throws IllegalArgumentException {
+ public void remove(String groupId, String artifactId, String topic) {
if (groupId == null || groupId.isEmpty())
- throw new IllegalArgumentException("Invalid group id");
+ throw new IllegalArgumentException(INVALID_GROUP_ID_MSG);
if (artifactId == null || artifactId.isEmpty())
- throw new IllegalArgumentException("Invalid artifact id");
+ throw new IllegalArgumentException(INVALID_ARTIFACT_ID_MSG);
if (topic == null || topic.isEmpty())
- throw new IllegalArgumentException("Invalid Topic");
+ throw new IllegalArgumentException(INVALID_TOPIC_MSG);
String key = this.codersKey(groupId, artifactId, topic);
@@ -899,13 +878,13 @@ abstract class GenericEventProtocolCoder {
public boolean isCodingSupported(String groupId, String artifactId, String topic) {
if (groupId == null || groupId.isEmpty())
- throw new IllegalArgumentException("Invalid group id");
+ throw new IllegalArgumentException(INVALID_GROUP_ID_MSG);
if (artifactId == null || artifactId.isEmpty())
- throw new IllegalArgumentException("Invalid artifact id");
+ throw new IllegalArgumentException(INVALID_ARTIFACT_ID_MSG);
if (topic == null || topic.isEmpty())
- throw new IllegalArgumentException("Invalid Topic");
+ throw new IllegalArgumentException(INVALID_TOPIC_MSG);
String key = this.codersKey(groupId, artifactId, topic);
synchronized(this) {
@@ -924,8 +903,7 @@ abstract class GenericEventProtocolCoder {
* @throws IllegalArgumentException if invalid argument is provided
* @throws UnsupportedOperationException if the operation cannot be performed
*/
- public Object decode(String groupId, String artifactId, String topic, String json)
- throws IllegalArgumentException, UnsupportedOperationException, IllegalStateException {
+ public Object decode(String groupId, String artifactId, String topic, String json) {
if (!isCodingSupported(groupId, artifactId, topic))
throw new IllegalArgumentException("Unsupported:" + codersKey(groupId, artifactId, topic) + " for encoding");
@@ -974,8 +952,7 @@ abstract class GenericEventProtocolCoder {
* @throws IllegalArgumentException if invalid argument is provided
* @throws UnsupportedOperationException if the operation cannot be performed
*/
- public String encode(String groupId, String artifactId, String topic, Object event)
- throws IllegalArgumentException, UnsupportedOperationException {
+ public String encode(String groupId, String artifactId, String topic, Object event) {
if (!isCodingSupported(groupId, artifactId, topic))
throw new IllegalArgumentException
@@ -998,8 +975,7 @@ abstract class GenericEventProtocolCoder {
* @throws IllegalArgumentException if invalid argument is provided
* @throws UnsupportedOperationException if the operation cannot be performed
*/
- protected String encodeInternal(String key, Object event)
- throws IllegalArgumentException, UnsupportedOperationException {
+ protected String encodeInternal(String key, Object event) {
logger.debug("{}: encode for {}: {}", this, key, event);
@@ -1045,8 +1021,7 @@ abstract class GenericEventProtocolCoder {
* @throws IllegalArgumentException if invalid argument is provided
* @throws UnsupportedOperationException if the operation cannot be performed
*/
- public String encode(String topic, Object event)
- throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException {
+ public String encode(String topic, Object event) {
if (event == null)
throw new IllegalArgumentException("Invalid encoded class");
@@ -1074,8 +1049,7 @@ abstract class GenericEventProtocolCoder {
* @throws IllegalArgumentException if invalid argument is provided
* @throws UnsupportedOperationException if the operation cannot be performed
*/
- public String encode(String topic, Object encodedClass, DroolsController droolsController)
- throws IllegalArgumentException, IllegalArgumentException, UnsupportedOperationException {
+ public String encode(String topic, Object encodedClass, DroolsController droolsController) {
if (encodedClass == null)
throw new IllegalArgumentException("Invalid encoded class");
@@ -1095,8 +1069,7 @@ abstract class GenericEventProtocolCoder {
* @throws IllegalStateException
* @throws IllegalArgumentException
*/
- protected List<DroolsController> droolsCreators(String topic, Object encodedClass)
- throws IllegalStateException, IllegalArgumentException {
+ protected List<DroolsController> droolsCreators(String topic, Object encodedClass) {
List<DroolsController> droolsControllers = new ArrayList<>();
@@ -1152,8 +1125,7 @@ abstract class GenericEventProtocolCoder {
* @return list of coders
* @throws IllegalArgumentException if invalid input
*/
- public List<CoderFilters> getFilters(String groupId, String artifactId, String topic)
- throws IllegalArgumentException {
+ public List<CoderFilters> getFilters(String groupId, String artifactId, String topic) {
if (!isCodingSupported(groupId, artifactId, topic))
throw new IllegalArgumentException("Unsupported:" + codersKey(groupId, artifactId, topic));
@@ -1172,15 +1144,13 @@ abstract class GenericEventProtocolCoder {
* @return list of coders
* @throws IllegalArgumentException if invalid input
*/
- public Pair<ProtocolCoderToolset,ProtocolCoderToolset> getCoders(String groupId, String artifactId, String topic)
- throws IllegalArgumentException {
+ public Pair<ProtocolCoderToolset,ProtocolCoderToolset> getCoders(String groupId, String artifactId, String topic) {
if (!isCodingSupported(groupId, artifactId, topic))
throw new IllegalArgumentException("Unsupported:" + codersKey(groupId, artifactId, topic));
String key = this.codersKey(groupId, artifactId, topic);
- Pair<ProtocolCoderToolset,ProtocolCoderToolset> coderTools = coders.get(key);
- return coderTools;
+ return coders.get(key);
}
/**
@@ -1191,14 +1161,13 @@ abstract class GenericEventProtocolCoder {
* @return list of coders
* @throws IllegalArgumentException if invalid input
*/
- public List<CoderFilters> getFilters(String groupId, String artifactId)
- throws IllegalArgumentException {
+ public List<CoderFilters> getFilters(String groupId, String artifactId) {
if (groupId == null || groupId.isEmpty())
- throw new IllegalArgumentException("Invalid group id");
+ throw new IllegalArgumentException(INVALID_GROUP_ID_MSG);
if (artifactId == null || artifactId.isEmpty())
- throw new IllegalArgumentException("Invalid artifact id");
+ throw new IllegalArgumentException(INVALID_ARTIFACT_ID_MSG);
String key = this.codersKey(groupId, artifactId, "");
@@ -1220,14 +1189,13 @@ abstract class GenericEventProtocolCoder {
* @return list of coders
* @throws IllegalArgumentException if invalid input
*/
- public List<Pair<ProtocolCoderToolset,ProtocolCoderToolset>> getCoders(String groupId, String artifactId)
- throws IllegalArgumentException {
+ public List<Pair<ProtocolCoderToolset,ProtocolCoderToolset>> getCoders(String groupId, String artifactId) {
if (groupId == null || groupId.isEmpty())
- throw new IllegalArgumentException("Invalid group id");
+ throw new IllegalArgumentException(INVALID_GROUP_ID_MSG);
if (artifactId == null || artifactId.isEmpty())
- throw new IllegalArgumentException("Invalid artifact id");
+ throw new IllegalArgumentException(INVALID_ARTIFACT_ID_MSG);
String key = this.codersKey(groupId, artifactId, "");
@@ -1252,8 +1220,7 @@ abstract class GenericEventProtocolCoder {
* @return list of coders
* @throws IllegalArgumentException if invalid input
*/
- public CoderFilters getFilters(String groupId, String artifactId, String topic, String classname)
- throws IllegalArgumentException {
+ public CoderFilters getFilters(String groupId, String artifactId, String topic, String classname) {
if (!isCodingSupported(groupId, artifactId, topic))
throw new IllegalArgumentException("Unsupported:" + codersKey(groupId, artifactId, topic));
@@ -1274,14 +1241,13 @@ abstract class GenericEventProtocolCoder {
* @return
* @throws IllegalArgumentException
*/
- public List<CoderFilters> getReverseFilters(String topic, String codedClass)
- throws IllegalArgumentException {
+ public List<CoderFilters> getReverseFilters(String topic, String codedClass) {
if (topic == null || topic.isEmpty())
- throw new IllegalArgumentException("Unsupported");
+ throw new IllegalArgumentException(UNSUPPORTED_MSG);
if (codedClass == null)
- throw new IllegalArgumentException("class must be provided");
+ throw new IllegalArgumentException(MISSING_CLASS);
String key = this.reverseCodersKey(topic, codedClass);
List<Pair<ProtocolCoderToolset,ProtocolCoderToolset>> toolsets = this.reverseCoders.get(key);
@@ -1305,14 +1271,13 @@ abstract class GenericEventProtocolCoder {
* @return
* @throws IllegalArgumentException
*/
- DroolsController getDroolsController(String topic, Object fact)
- throws IllegalArgumentException {
+ DroolsController getDroolsController(String topic, Object fact) {
if (topic == null || topic.isEmpty())
- throw new IllegalArgumentException("Unsupported");
+ throw new IllegalArgumentException(UNSUPPORTED_MSG);
if (fact == null)
- throw new IllegalArgumentException("class must be provided");
+ throw new IllegalArgumentException(MISSING_CLASS);
List<DroolsController> droolsControllers = droolsCreators(topic, fact);
@@ -1335,14 +1300,13 @@ abstract class GenericEventProtocolCoder {
* @return
* @throws IllegalArgumentException
*/
- List<DroolsController> getDroolsControllers(String topic, Object fact)
- throws IllegalArgumentException {
+ List<DroolsController> getDroolsControllers(String topic, Object fact) {
if (topic == null || topic.isEmpty())
- throw new IllegalArgumentException("Unsupported");
+ throw new IllegalArgumentException(UNSUPPORTED_MSG);
if (fact == null)
- throw new IllegalArgumentException("class must be provided");
+ throw new IllegalArgumentException(MISSING_CLASS);
List<DroolsController> droolsControllers = droolsCreators(topic, fact);
if (droolsControllers.size() > 1) {
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java
index c5f82a47..a5902d66 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java
@@ -1,4 +1,4 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
@@ -37,6 +37,7 @@ import com.google.gson.JsonParser;
*/
public class JsonProtocolFilter {
+ private static final String MISSING_RULE_NAME = "no rule name provided";
/**
* Logger
*/
@@ -128,35 +129,11 @@ public class JsonProtocolFilter {
protected List<FilterRule> rules = new CopyOnWriteArrayList<>();
/**
- *
- * @param rawFilters raw filter initialization
- *
- * @throws IllegalArgumentException an invalid input has been provided
- */
- public static JsonProtocolFilter fromRawFilters(List<Pair<String, String>> rawFilters)
- throws IllegalArgumentException {
-
- if (rawFilters == null) {
- throw new IllegalArgumentException("No raw filters provided");
- }
-
- List<FilterRule> filters = new ArrayList<>();
- for (Pair<String, String> filterPair: rawFilters) {
- if (filterPair.first() == null || filterPair.first().isEmpty()) {
- continue;
- }
-
- filters.add(new FilterRule(filterPair.first(), filterPair.second()));
- }
- return new JsonProtocolFilter(filters);
- }
-
- /**
* Create a Protocol Filter
*
* @throws IllegalArgumentException an invalid input has been provided
*/
- public JsonProtocolFilter() throws IllegalArgumentException {}
+ public JsonProtocolFilter() {}
/**
*
@@ -164,7 +141,7 @@ public class JsonProtocolFilter {
*
* @throws IllegalArgumentException an invalid input has been provided
*/
- public JsonProtocolFilter(List<FilterRule> filters) throws IllegalArgumentException {
+ public JsonProtocolFilter(List<FilterRule> filters) {
List<FilterRule> temp = new ArrayList<>();
for (FilterRule rule : filters) {
if (rule.getName() == null || rule.getName().isEmpty()) {
@@ -180,6 +157,29 @@ public class JsonProtocolFilter {
this.rules.addAll(temp);
}
+
+ /**
+ *
+ * @param rawFilters raw filter initialization
+ *
+ * @throws IllegalArgumentException an invalid input has been provided
+ */
+ public static JsonProtocolFilter fromRawFilters(List<Pair<String, String>> rawFilters) {
+
+ if (rawFilters == null) {
+ throw new IllegalArgumentException("No raw filters provided");
+ }
+
+ List<FilterRule> filters = new ArrayList<>();
+ for (Pair<String, String> filterPair: rawFilters) {
+ if (filterPair.first() == null || filterPair.first().isEmpty()) {
+ continue;
+ }
+
+ filters.add(new FilterRule(filterPair.first(), filterPair.second()));
+ }
+ return new JsonProtocolFilter(filters);
+ }
/**
* are there any filters?
@@ -198,7 +198,7 @@ public class JsonProtocolFilter {
*
* @throws IllegalArgumentException an invalid input has been provided
*/
- public boolean accept(JsonElement json) throws IllegalArgumentException {
+ public boolean accept(JsonElement json) {
if (json == null) {
throw new IllegalArgumentException("no JSON provided");
}
@@ -248,7 +248,7 @@ public class JsonProtocolFilter {
*
* @throws IllegalArgumentException an invalid input has been provided
*/
- public boolean accept(String json) throws IllegalArgumentException {
+ public boolean accept(String json) {
if (json == null || json.isEmpty()) {
throw new IllegalArgumentException("no JSON provided");
}
@@ -279,7 +279,7 @@ public class JsonProtocolFilter {
public List<FilterRule> getRules(String name) {
if (name == null || name.isEmpty())
- throw new IllegalArgumentException("no rule name provided");
+ throw new IllegalArgumentException(MISSING_RULE_NAME);
ArrayList<FilterRule> temp = new ArrayList<>();
for (FilterRule rule : this.rules) {
@@ -300,7 +300,7 @@ public class JsonProtocolFilter {
public void deleteRules(String name) {
if (name == null || name.isEmpty())
- throw new IllegalArgumentException("no rule name provided");
+ throw new IllegalArgumentException(MISSING_RULE_NAME);
List<FilterRule> temp = new ArrayList<>();
for (FilterRule rule : this.rules) {
@@ -313,7 +313,7 @@ public class JsonProtocolFilter {
public void deleteRule(String name, String regex) {
if (name == null || name.isEmpty())
- throw new IllegalArgumentException("no rule name provided");
+ throw new IllegalArgumentException(MISSING_RULE_NAME);
String nonNullRegex = regex;
if (regex == null || regex.isEmpty()) {
@@ -332,7 +332,7 @@ public class JsonProtocolFilter {
public void addRule(String name, String regex) {
if (name == null || name.isEmpty())
- throw new IllegalArgumentException("no rule name provided");
+ throw new IllegalArgumentException(MISSING_RULE_NAME);
String nonNullRegex = regex;
if (regex == null || regex.isEmpty()) {
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java
index cb039ee5..7ee8b08a 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java
@@ -1,4 +1,4 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
@@ -20,21 +20,6 @@
package org.onap.policy.drools.protocol.coders;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
@@ -44,6 +29,7 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
+
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.protocol.coders.EventProtocolCoder.CoderFilters;
import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration.CustomCoder;
@@ -52,6 +38,21 @@ import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration.Cust
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
/**
* Protocol Coding/Decoding Toolset
*/
@@ -109,7 +110,7 @@ public abstract class ProtocolCoderToolset {
*/
public ProtocolCoderToolset(String topic, String controllerId, String groupId, String artifactId,
String codedClass, JsonProtocolFilter filters, CustomCoder customCoder,
- int modelClassLoaderHash) throws IllegalArgumentException {
+ int modelClassLoaderHash) {
if (topic == null || controllerId == null || groupId == null || artifactId == null
|| codedClass == null || filters == null || topic.isEmpty() || controllerId.isEmpty()) {
@@ -243,8 +244,7 @@ public abstract class ProtocolCoderToolset {
* @throws UnsupportedOperationException can't filter
* @throws IllegalArgumentException invalid input
*/
- protected CoderFilters filter(String json)
- throws UnsupportedOperationException, IllegalArgumentException, IllegalStateException {
+ protected CoderFilters filter(String json) {
// 1. Get list of decoding classes for this controller Id and topic
@@ -297,8 +297,7 @@ public abstract class ProtocolCoderToolset {
* @throws IllegalArgumentException if an invalid parameter has been received
* @throws UnsupportedOperationException if parsing into POJO is not possible
*/
- public abstract Object decode(String json)
- throws IllegalArgumentException, UnsupportedOperationException, IllegalStateException;
+ public abstract Object decode(String json);
/**
* Encodes a POJO object into a JSON String
@@ -308,8 +307,7 @@ public abstract class ProtocolCoderToolset {
* @throws IllegalArgumentException if an invalid parameter has been received
* @throws UnsupportedOperationException if parsing into POJO is not possible
*/
- public abstract String encode(Object event)
- throws IllegalArgumentException, UnsupportedOperationException;
+ public abstract String encode(Object event);
@Override
public String toString() {
@@ -328,7 +326,11 @@ public abstract class ProtocolCoderToolset {
* Tools used for encoding/decoding using Jackson
*/
class JacksonProtocolCoderToolset extends ProtocolCoderToolset {
- private static Logger logger = LoggerFactory.getLogger(JacksonProtocolCoderToolset.class);
+ private static final String WARN_FETCH_FAILED = "{}: cannot fetch application class {}";
+private static final String WARN_FETCH_FAILED_BECAUSE = "{}: cannot fetch application class {} because of {}";
+private static final String FETCH_FAILED = "cannot fetch application class ";
+private static final String ENCODE_FAILED = "event cannot be encoded";
+private static Logger logger = LoggerFactory.getLogger(JacksonProtocolCoderToolset.class);
/**
* decoder
*/
@@ -381,8 +383,7 @@ class JacksonProtocolCoderToolset extends ProtocolCoderToolset {
* {@inheritDoc}
*/
@Override
- public Object decode(String json)
- throws IllegalArgumentException, UnsupportedOperationException, IllegalStateException {
+ public Object decode(String json) {
// 0. Use custom coder if available
@@ -408,21 +409,20 @@ class JacksonProtocolCoderToolset extends ProtocolCoderToolset {
try {
decoderClass = droolsController.fetchModelClass(decoderFilter.getCodedClass());
if (decoderClass == null) {
- logger.warn("{}: cannot fetch application class {}", this, decoderFilter.getCodedClass());
+ logger.warn(WARN_FETCH_FAILED, this, decoderFilter.getCodedClass());
throw new IllegalStateException(
- "cannot fetch application class " + decoderFilter.getCodedClass());
+ FETCH_FAILED + decoderFilter.getCodedClass());
}
} catch (final Exception e) {
- logger.warn("{}: cannot fetch application class {} because of {}", this,
+ logger.warn(WARN_FETCH_FAILED_BECAUSE, this,
decoderFilter.getCodedClass(), e.getMessage());
throw new UnsupportedOperationException(
- "cannot fetch application class " + decoderFilter.getCodedClass(), e);
+ FETCH_FAILED + decoderFilter.getCodedClass(), e);
}
try {
- final Object fact = this.decoder.readValue(json, decoderClass);
- return fact;
+ return this.decoder.readValue(json, decoderClass);
} catch (final Exception e) {
logger.warn("{} cannot decode {} into {} because of {}", this, json, decoderClass.getName(),
e.getMessage(), e);
@@ -435,8 +435,7 @@ class JacksonProtocolCoderToolset extends ProtocolCoderToolset {
* {@inheritDoc}
*/
@Override
- public String encode(Object event)
- throws IllegalArgumentException, UnsupportedOperationException {
+ public String encode(Object event) {
// 0. Use custom coder if available
@@ -446,11 +445,10 @@ class JacksonProtocolCoderToolset extends ProtocolCoderToolset {
}
try {
- final String encodedEvent = this.encoder.writeValueAsString(event);
- return encodedEvent;
+ return this.encoder.writeValueAsString(event);
} catch (final JsonProcessingException e) {
logger.error("{} cannot encode {} because of {}", this, event, e.getMessage(), e);
- throw new UnsupportedOperationException("event cannot be encoded");
+ throw new UnsupportedOperationException(ENCODE_FAILED);
}
}
@@ -491,7 +489,7 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
@Override
public ZonedDateTime deserialize(JsonElement element, Type type,
- JsonDeserializationContext context) throws JsonParseException {
+ JsonDeserializationContext context) {
try {
return ZonedDateTime.parse(element.getAsString(), format);
} catch (final Exception e) {
@@ -511,8 +509,7 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
@Override
- public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
return Instant.ofEpochMilli(json.getAsLong());
}
@@ -578,8 +575,7 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
* {@inheritDoc}
*/
@Override
- public Object decode(String json)
- throws IllegalArgumentException, UnsupportedOperationException, IllegalStateException {
+ public Object decode(String json) {
final DroolsController droolsController =
DroolsController.factory.get(this.groupId, this.artifactId, "");
@@ -617,8 +613,7 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
final Object gsonObject = gsonField.get(null);
final Method fromJsonMethod = gsonObject.getClass().getDeclaredMethod("fromJson",
new Class[] {String.class, Class.class});
- final Object fact = fromJsonMethod.invoke(gsonObject, json, decoderClass);
- return fact;
+ return fromJsonMethod.invoke(gsonObject, json, decoderClass);
} catch (final Exception e) {
logger.warn("{}: cannot fetch application class {} because of {}", this,
decoderFilter.getCodedClass(), e.getMessage());
@@ -627,8 +622,7 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
}
} else {
try {
- final Object fact = this.decoder.fromJson(json, decoderClass);
- return fact;
+ return this.decoder.fromJson(json, decoderClass);
} catch (final Exception e) {
logger.warn("{} cannot decode {} into {} because of {}", this, json, decoderClass.getName(),
e.getMessage(), e);
@@ -644,8 +638,7 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
* {@inheritDoc}
*/
@Override
- public String encode(Object event)
- throws IllegalArgumentException, UnsupportedOperationException {
+ public String encode(Object event) {
if (this.customCoder != null) {
try {
@@ -657,8 +650,7 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
final Object gsonObject = gsonField.get(null);
final Method toJsonMethod =
gsonObject.getClass().getDeclaredMethod("toJson", new Class[] {Object.class});
- final String encodedJson = (String) toJsonMethod.invoke(gsonObject, event);
- return encodedJson;
+ return (String) toJsonMethod.invoke(gsonObject, event);
} catch (final Exception e) {
logger.warn("{} cannot custom-encode {} because of {}", this, event, e.getMessage(), e);
throw new UnsupportedOperationException("event cannot be encoded", e);
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java
index 93737267..7c1b128f 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java
@@ -1,8 +1,8 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* policy-management
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ public class TopicCoderFilterConfiguration {
* Custom coder, contains class and static field to access parser that the controller
* desires to use instead of the framework provided parser
*/
- public static abstract class CustomCoder {
+ public abstract static class CustomCoder {
protected String className;
protected String staticCoderField;
@@ -41,7 +41,7 @@ public class TopicCoderFilterConfiguration {
*
* @param rawCustomCoder with format: <class-containing-custom-coder>,<static-coder-field>
*/
- public CustomCoder(String rawCustomCoder) throws IllegalArgumentException {
+ public CustomCoder(String rawCustomCoder) {
if (rawCustomCoder != null && !rawCustomCoder.isEmpty()) {
this.className = rawCustomCoder.substring(0,rawCustomCoder.indexOf(","));
@@ -62,7 +62,7 @@ public class TopicCoderFilterConfiguration {
* @param classContainer
* @param staticCoderField
*/
- public CustomCoder(String className, String staticCoderField) throws IllegalArgumentException {
+ public CustomCoder(String className, String staticCoderField) {
if (className == null || className.isEmpty()) {
throw new IllegalArgumentException("No classname to create CustomCoder cannot be created");
}
@@ -120,7 +120,7 @@ public class TopicCoderFilterConfiguration {
super(className, staticCoderField);
}
- public CustomGsonCoder(String customGson) throws IllegalArgumentException {
+ public CustomGsonCoder(String customGson) {
super(customGson);
}
@@ -139,7 +139,7 @@ public class TopicCoderFilterConfiguration {
super(className, staticCoderField);
}
- public CustomJacksonCoder(String customJackson) throws IllegalArgumentException {
+ public CustomJacksonCoder(String customJackson) {
super(customJackson);
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java
index 845c4944..62b66611 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java
@@ -1,8 +1,8 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* policy-management
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,7 +68,7 @@ public class ControllerConfiguration {
private DroolsConfiguration drools;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<>();
- protected final static Object NOT_FOUND_VALUE = new Object();
+ protected static final Object NOT_FOUND_VALUE = new Object();
/**
* No args constructor for use in serialization
@@ -259,7 +259,7 @@ public class ControllerConfiguration {
if (other == this) {
return true;
}
- if ((other instanceof ControllerConfiguration) == false) {
+ if (!(other instanceof ControllerConfiguration)) {
return false;
}
ControllerConfiguration rhs = ((ControllerConfiguration) other);
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java
index e822d88e..cac4f565 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java
@@ -1,8 +1,8 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* policy-management
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@ public class DroolsConfiguration {
private String version;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<>();
- protected final static Object NOT_FOUND_VALUE = new Object();
+ protected static final Object NOT_FOUND_VALUE = new Object();
/**
* No args constructor for use in serialization
@@ -257,7 +257,7 @@ public class DroolsConfiguration {
if (other == this) {
return true;
}
- if ((other instanceof DroolsConfiguration) == false) {
+ if (!(other instanceof DroolsConfiguration)) {
return false;
}
DroolsConfiguration rhs = ((DroolsConfiguration) other);
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
index c7a227b1..29888bbb 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
@@ -1,8 +1,8 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* policy-management
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -70,7 +70,7 @@ public class PdpdConfiguration {
private List<ControllerConfiguration> controllers = new ArrayList<>();
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<>();
- protected final static Object NOT_FOUND_VALUE = new Object();
+ protected static final Object NOT_FOUND_VALUE = new Object();
/**
* No args constructor for use in serialization
@@ -197,8 +197,7 @@ public class PdpdConfiguration {
return this;
}
- @SuppressWarnings("unchecked")
- protected boolean declaredProperty(String name, Object value) {
+ protected boolean declaredProperty(String name, Object value) {
switch (name) {
case "requestID":
callSetRequestId(value);
@@ -262,7 +261,7 @@ public class PdpdConfiguration {
if (other == this) {
return true;
}
- if ((other instanceof PdpdConfiguration) == false) {
+ if (!(other instanceof PdpdConfiguration)) {
return false;
}
PdpdConfiguration rhs = (PdpdConfiguration) other;
@@ -285,7 +284,8 @@ public class PdpdConfiguration {
}
}
- public void callSetControllers(Object value) {
+ @SuppressWarnings("unchecked")
+ public void callSetControllers(Object value) {
if (value instanceof List) {
setControllers((List<ControllerConfiguration> ) value);
} else {