From 5a8fe222ebc4485fae7e78be8e9926d6e51ac93a Mon Sep 17 00:00:00 2001 From: rama-huawei Date: Thu, 21 Sep 2017 15:40:11 +0530 Subject: Added @Override method Added diamond symbol on RHS Removed useless parentheses Issue-ID: POLICY-239 Change-Id: Ie20319a5a7298c70a18cc3773ec47f235dbdae41 Signed-off-by: rama-huawei --- .../drools/protocol/coders/EventProtocolCoder.java | 30 +++++++++++----------- .../drools/protocol/coders/JsonProtocolFilter.java | 4 +-- .../protocol/coders/ProtocolCoderToolset.java | 5 ++-- 3 files changed, 20 insertions(+), 19 deletions(-) (limited to 'policy-management') 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 762f4476..6f14076f 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 @@ -670,13 +670,13 @@ abstract class GenericEventProtocolCoder { * and consequently the second value will be the less likely. */ protected final HashMap> coders = - new HashMap>(); + new HashMap<>(); /** * Mapping topic + classname -> Protocol Set */ protected final HashMap>> reverseCoders = - new HashMap>>(); + new HashMap<>(); protected boolean multipleToolsetRetries = false; @@ -735,7 +735,7 @@ abstract class GenericEventProtocolCoder { this, reverseKey, key, toolsets.first()); List> reverseMappings = - new ArrayList>(); + new ArrayList<>(); reverseMappings.add(toolsets); reverseCoders.put(reverseKey, reverseMappings); } @@ -767,7 +767,7 @@ abstract class GenericEventProtocolCoder { // are detected in the gson encoding Pair coderTools = - new Pair(gsonCoderTools, + new Pair<>(gsonCoderTools, jacksonCoderTools); logger.info("{}: adding coders for new {}: {}", this, key, coderTools.first()); @@ -800,7 +800,7 @@ abstract class GenericEventProtocolCoder { } } else { List> toolsets = - new ArrayList>(); + new ArrayList<>(); toolsets.add(coderTools); logger.info("{}: adding toolset for reverse key {}: {}", this, reverseKey, toolsets); @@ -909,7 +909,7 @@ abstract class GenericEventProtocolCoder { String key = this.codersKey(groupId, artifactId, topic); synchronized(this) { - return (coders.containsKey(key)); + return coders.containsKey(key); } } @@ -1102,7 +1102,7 @@ abstract class GenericEventProtocolCoder { protected List droolsCreators(String topic, Object encodedClass) throws IllegalStateException, IllegalArgumentException { - List droolsControllers = new ArrayList(); + List droolsControllers = new ArrayList<>(); String reverseKey = this.reverseCodersKey(topic, encodedClass.getClass().getCanonicalName()); if (!this.reverseCoders.containsKey(reverseKey)) { @@ -1127,8 +1127,8 @@ abstract class GenericEventProtocolCoder { // figure out the right toolset String groupId = encoderSet.first().getGroupId(); String artifactId = encoderSet.first().getArtifactId(); - List coders = encoderSet.first().getCoders(); - for (CoderFilters coder : coders) { + List coderFilters = encoderSet.first().getCoders(); + for (CoderFilters coder : coderFilters) { if (coder.getCodedClass().equals(encodedClass.getClass().getCanonicalName())) { DroolsController droolsController = DroolsController.factory.get(groupId, artifactId, ""); @@ -1206,7 +1206,7 @@ abstract class GenericEventProtocolCoder { String key = this.codersKey(groupId, artifactId, ""); - List codersFilters = new ArrayList(); + List codersFilters = new ArrayList<>(); for (Map.Entry> entry : coders.entrySet()) { if (entry.getKey().startsWith(key)) { codersFilters.addAll(entry.getValue().first().getCoders()); @@ -1235,7 +1235,7 @@ abstract class GenericEventProtocolCoder { String key = this.codersKey(groupId, artifactId, ""); - List> coderToolset = new ArrayList>(); + List> coderToolset = new ArrayList<>(); for (Map.Entry> entry : coders.entrySet()) { if (entry.getKey().startsWith(key)) { coderToolset.add(entry.getValue()); @@ -1293,12 +1293,12 @@ abstract class GenericEventProtocolCoder { throw new IllegalArgumentException("No Coder found for " + key); - List coders = new ArrayList(); + List coderFilters = new ArrayList<>(); for (Pair toolset: toolsets) { - coders.addAll(toolset.first().getCoders()); + coderFilters.addAll(toolset.first().getCoders()); } - return coders; + return coderFilters; } /** @@ -1390,4 +1390,4 @@ class EventProtocolEncoder extends GenericEventProtocolCoder { builder.append("EventProtocolEncoder [toString()=").append(super.toString()).append("]"); return builder.toString(); } -} \ No newline at end of file +} 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 6afeb26a..0a52d254 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 @@ -119,7 +119,7 @@ public class JsonProtocolFilter { /** * all the filters to be applied */ - protected List rules = new ArrayList(); + protected List rules = new ArrayList<>(); /** * @@ -134,7 +134,7 @@ public class JsonProtocolFilter { throw new IllegalArgumentException("No raw filters provided"); } - List filters = new ArrayList(); + List filters = new ArrayList<>(); for (Pair filterPair: rawFilters) { if (filterPair.first() == null || filterPair.first().isEmpty()) { continue; 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 1c8dafea..df51473d 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 @@ -87,7 +87,7 @@ public abstract class ProtocolCoderToolset { /** * Protocols and associated Filters */ - protected final List coders = new ArrayList(); + protected final List coders = new ArrayList<>(); /** * Tree model (instead of class model) generic parsing to be able to inspect elements @@ -488,7 +488,7 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset { * Adapter for ZonedDateTime */ public static class GsonUTCAdapter implements JsonSerializer, JsonDeserializer { - + @Override public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException { try { @@ -500,6 +500,7 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset { return null; } + @Override public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) { return new JsonPrimitive(datetime.format(format)); } -- cgit 1.2.3-korg