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/persistence/DroolsSessionEntity.java | 9 ++++--- .../drools/persistence/PersistenceFeature.java | 26 +++++++++---------- .../drools/protocol/coders/EventProtocolCoder.java | 30 +++++++++++----------- .../drools/protocol/coders/JsonProtocolFilter.java | 4 +-- .../protocol/coders/ProtocolCoderToolset.java | 5 ++-- 5 files changed, 38 insertions(+), 36 deletions(-) diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java index 71f5ec9a..e9c5b33b 100644 --- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java +++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java @@ -91,22 +91,23 @@ public class DroolsSessionEntity implements Serializable, DroolsSession { public void setSessionId(long sessionId) { this.sessionId = sessionId; } - + + @Override public Date getCreatedDate() { return createdDate; } - + @Override public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } - + @Override public Date getUpdatedDate() { return updatedDate; } - + @Override public void setUpdatedDate(Date updatedDate) { this.updatedDate = updatedDate; } diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java index b48690b0..db33d05a 100644 --- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java +++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java @@ -143,7 +143,7 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine policyContainer.setAdjunct(this, rval); } - return ((ContainerAdjunct) rval); + return (ContainerAdjunct) rval; } /** @@ -151,7 +151,7 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine */ @Override public int getSequenceNumber() { - return (1); + return 1; } /** @@ -201,9 +201,9 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine public PolicySession.ThreadModel selectThreadModel(PolicySession session) { PolicyContainer policyContainer = session.getPolicyContainer(); if (isPersistenceEnabled(policyContainer, session.getName())) { - return (new PersistentThreadModel(session, getProperties(policyContainer))); + return new PersistentThreadModel(session, getProperties(policyContainer)); } - return (null); + return null; } /** @@ -372,8 +372,8 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine KieSessionConfiguration kConf = kieSvcFact.newKieSessionConfiguration(); - KieSession kieSession = (desiredSessionId >= 0 ? loadKieSession(kieBaseName, desiredSessionId, env, kConf) - : null); + KieSession kieSession = desiredSessionId >= 0 ? loadKieSession(kieBaseName, desiredSessionId, env, kConf) + : null; if (kieSession == null) { // loadKieSession() returned null or desiredSessionId < 0 @@ -609,7 +609,7 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine */ private long getSessionId(DroolsSessionConnector conn, String sessnm) { DroolsSession sess = conn.get(sessnm); - return (sess != null ? sess.getSessionId() : -1); + return sess != null ? sess.getSessionId() : -1; } /** @@ -650,10 +650,10 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine if (properties != null) { // fetch the 'type' property String type = getProperty(properties, sessionName, "type"); - rval = ("auto".equals(type) || "native".equals(type)); + rval = "auto".equals(type) || "native".equals(type); } - return (rval); + return rval; } /** @@ -665,10 +665,10 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine */ private Properties getProperties(PolicyContainer container) { try { - return (fact.getPolicyContainer(container).getProperties()); + return fact.getPolicyContainer(container).getProperties(); } catch (IllegalArgumentException e) { logger.error("getProperties exception: ", e); - return (null); + return null; } } @@ -694,7 +694,7 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine value = properties.getProperty("persistence." + property); } - return (value); + return value; } /* ============================================================ */ @@ -790,7 +790,7 @@ public class PersistenceFeature implements PolicySessionFeatureAPI, PolicyEngine * @return the String to use as the thread name */ private String getThreadName() { - return ("Session " + session.getFullName() + " (persistent)"); + return "Session " + session.getFullName() + " (persistent)"; } /***************************/ 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