fixed major sonar issues in SpringServiceImpl.java 79/65879/1
authorSandeep J <sandeejh@in.ibm.com>
Tue, 11 Sep 2018 15:53:11 +0000 (21:23 +0530)
committerSandeep J <sandeejh@in.ibm.com>
Tue, 11 Sep 2018 15:54:18 +0000 (21:24 +0530)
fixed sonar issues as detailed in CCSDK-526

Issue-ID: CCSDK-526
Change-Id: Ie00d7147e5ddfc596e9b5484a7aef4984204bab2
Signed-off-by: Sandeep J <sandeejh@in.ibm.com>
ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java

index 79e4657..daf8f57 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -94,12 +96,12 @@ public class SpringServiceImpl implements SpringService {
     @Transactional(rollbackOn = Exception.class)
     public NameGenResponse genNetworkElementName(NameGenRequest request) throws Exception {
         try {
-            Map<String, Map<String, String>> earlierNames = new HashMap<String, Map<String, String>>();
-            List<Map<String, String>> allElements = new ArrayList<Map<String, String>>();
-            Map<String, Map<String, ?>> policyCache = new HashMap<String, Map<String, ?>>();
-            List<Map<String, String>> generatedNames = new ArrayList<Map<String, String>>();
+            Map<String, Map<String, String>> earlierNames = new HashMap<>();
+            List<Map<String, String>> allElements = new ArrayList<>();
+            Map<String, Map<String, ?>> policyCache = new HashMap<>();
+            List<Map<String, String>> generatedNames = new ArrayList<>();
             validateRequest(request);
-            if (request.getElements() != null && request.getElements().size() > 0) {
+            if (!request.getElements().isEmpty()) {
                 allElements.addAll(request.getElements());
             }
             PolicyFinder policyFinderImpl = findPolicyFinderImpl(request);
@@ -194,7 +196,7 @@ public class SpringServiceImpl implements SpringService {
 
     void validateRequest(NameGenRequest request) throws Exception {
         List<Map<String, String>> elems = request.getElements();
-        if (elems != null && elems.size() > 0) {
+        if (!elems.isEmpty()) {
             boolean error = false;
             Set<String> externalKeySet = elems.stream().map(s -> s.get("external-key")).collect(Collectors.toSet());
             if (externalKeySet.size() != request.getElements().size()) {