Improvements in JsonUtilForPnfCorrelationId 64/89564/2
authorr.bogacki <r.bogacki@samsung.com>
Fri, 7 Jun 2019 08:19:23 +0000 (10:19 +0200)
committerRobert Bogacki <r.bogacki@samsung.com>
Mon, 10 Jun 2019 06:27:20 +0000 (06:27 +0000)
General fixes and improvements according to the Sonar analysis
-Added private constructor for a utility class.
-Refactored lambda expression.

Issue-ID: SO-1992
Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
Change-Id: Ife8cfdf9c341dc89a1699fd616ec68cba734a5d5

bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java

index 7cb78a1..8010ce6 100644 (file)
@@ -5,6 +5,7 @@
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Copyright (C) 2018 Nokia.
+ * Modifications Copyright (c) 2019 Samsung
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,15 +36,18 @@ public final class JsonUtilForPnfCorrelationId {
 
     private static final String JSON_PNF_CORRELATION_ID_FIELD_NAME = "correlationId";
 
+    private JsonUtilForPnfCorrelationId() {
+        throw new IllegalStateException("Utility class");
+    }
+
     static List<String> parseJsonToGelAllPnfCorrelationId(String json) {
         JsonElement je = new JsonParser().parse(json);
         JsonArray array = je.getAsJsonArray();
         List<String> list = new ArrayList<>();
         Spliterator<JsonElement> spliterator = array.spliterator();
-        spliterator.forEachRemaining(jsonElement -> {
-            handleEscapedCharacters(jsonElement).ifPresent(jsonObject -> getPnfCorrelationId(jsonObject)
-                    .ifPresent(pnfCorrelationId -> list.add(pnfCorrelationId)));
-        });
+        spliterator.forEachRemaining(jsonElement -> handleEscapedCharacters(jsonElement)
+                .ifPresent(jsonObject -> getPnfCorrelationId(jsonObject)
+                        .ifPresent(pnfCorrelationId -> list.add(pnfCorrelationId))));
         return list;
     }