diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2018-01-30 08:28:25 -0500 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2018-01-30 08:32:10 -0500 |
commit | 3ee17bad27b036a9e4ca6e50a7fbdfe2ed0a8e7f (patch) | |
tree | 3cce5097dc94fcc40ff59c57e2a3287946f72271 /POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java | |
parent | b65e96826d7339ce29ddb73e3ed6775bd4f54753 (diff) |
Fix technical debt and reduce lines
Focused on iterating over entrySet along with more fixes for
dead stores, unnecessary exceptions. I'm also starting to work
on reducing the number of code lines.
* Iterate using entrySet
* Remove useless assignments
* Unnecessary exceptions
* Use StringBuilder instead of StringBuffer due to synchronization
* Potential null exceptions being thrown
* Returning a empty collection vs null
Issue-ID: POLICY-482
Change-Id: If6ac8e812237f37b2b10c534535df4090a5073dd
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java')
-rw-r--r-- | POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java index 88cb2e265..a556beeaa 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java @@ -26,6 +26,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import javax.xml.bind.JAXBElement; @@ -166,8 +167,9 @@ public class ActionPolicyController extends RestrictedBaseController { AttributeValueType attributeValue = (AttributeValueType) attributeAssignmentExpression .getExpression().getValue(); if (attributeID.equals(PERFORMER_ATTRIBUTEID)) { - for (String key : performer.keySet()) { - String keyValue = performer.get(key); + for ( Entry<String, String> entry: performer.entrySet()) { + String key = entry.getKey(); + String keyValue = entry.getValue(); if (keyValue.equals(attributeValue.getContent().get(0))) { policyAdapter.setActionPerformer(key); } @@ -235,10 +237,9 @@ public class ActionPolicyController extends RestrictedBaseController { ruleMap.put("id", "A" + (index + 1)); // Populate combo box Map<String, String> dropDownMap = PolicyController.getDropDownMap(); - for (String key : dropDownMap.keySet()) { - String keyValue = dropDownMap.get(key); - if (keyValue.equals(actionApply.getFunctionId())) { - ruleMap.put("dynamicRuleAlgorithmCombo", key); + for ( Entry<String, String> entry : dropDownMap.entrySet()) { + if (entry.getValue().equals(actionApply.getFunctionId())) { + ruleMap.put("dynamicRuleAlgorithmCombo", entry.getKey()); } } // Populate the key and value fields |