aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2017-08-30 05:48:57 -0700
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2017-08-30 05:48:57 -0700
commitf13efdabda4ff77eedccf5595616c9423710f405 (patch)
tree5d3c0d2286a51af45aa32adfd854f78f1ba15649 /src/main/java
parentef2025c00c146ecf2b8ddfbef3ec7f49b1726f49 (diff)
Fix Sonar bugs
In OperationalPolicyReq.class Blocker issues fixed Change-Id: If35ab7674961c6d9c7558b1f81d7fd5fb22eae45 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java39
1 files changed, 14 insertions, 25 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java
index 950fcefe5..e7f956d33 100644
--- a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java
+++ b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java
@@ -23,6 +23,12 @@
package org.onap.clamp.clds.client.req;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFLogger.Level;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
@@ -31,7 +37,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.jboss.resteasy.spi.BadRequestException;
+import javax.ws.rs.BadRequestException;
+
import org.onap.clamp.clds.model.prop.Global;
import org.onap.clamp.clds.model.prop.ModelProperties;
import org.onap.clamp.clds.model.prop.PolicyChain;
@@ -52,12 +59,6 @@ import org.onap.policy.controlloop.policy.builder.ControlLoopPolicyBuilder;
import org.onap.policy.controlloop.policy.builder.Message;
import org.onap.policy.controlloop.policy.builder.Results;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFLogger.Level;
-import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
/**
* Construct an Operational Policy request given CLDS objects.
*/
@@ -426,16 +427,10 @@ public class OperationalPolicyReq {
* @return
*/
private static Resource[] convertToResource(List<String> stringList, ResourceType resourceType) {
- int size = 0;
- if (stringList != null) {
- size = stringList.size();
- }
- Resource[] resourceArray = new Resource[size];
- for (int i = 0; i < size; i++) {
- String rString = stringList.get(i);
- resourceArray[i] = new Resource(rString, resourceType);
+ if (stringList == null || stringList.isEmpty()) {
+ return new Resource[0];
}
- return resourceArray;
+ return stringList.stream().map(stringElem -> new Resource(stringElem, resourceType)).toArray(Resource[]::new);
}
/**
@@ -446,16 +441,10 @@ public class OperationalPolicyReq {
* @return
*/
private static PolicyResult[] convertToPolicyResult(List<String> prList) {
- int size = 0;
- if (prList != null) {
- size = prList.size();
- }
- PolicyResult[] prArray = new PolicyResult[size];
- for (int i = 0; i < size; i++) {
- String prString = prList.get(i);
- prArray[i] = PolicyResult.toResult(prString);
+ if (prList == null || prList.isEmpty()) {
+ return new PolicyResult[0];
}
- return prArray;
+ return prList.stream().map(stringElem -> PolicyResult.toResult(stringElem)).toArray(PolicyResult[]::new);
}
} \ No newline at end of file