From 9a1bd11106c62fbc6efdd7d46cb759fc60056ee9 Mon Sep 17 00:00:00 2001 From: "r.bogacki" Date: Fri, 7 Jun 2019 10:19:23 +0200 Subject: Improvements in JsonUtilForPnfCorrelationId 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 Change-Id: Ife8cfdf9c341dc89a1699fd616ec68cba734a5d5 --- .../pnf/dmaap/JsonUtilForPnfCorrelationId.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'bpmn/so-bpmn-infrastructure-common/src') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java index 7cb78a10e5..8010ce62ab 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java @@ -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 parseJsonToGelAllPnfCorrelationId(String json) { JsonElement je = new JsonParser().parse(json); JsonArray array = je.getAsJsonArray(); List list = new ArrayList<>(); Spliterator 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; } -- cgit 1.2.3-korg