From a4f4215c435414360f281b625705595be9367ace Mon Sep 17 00:00:00 2001 From: leventecsanyi Date: Thu, 8 Dec 2022 14:49:29 +0100 Subject: Fixing SonarQube violations - Code smell fixes Signed-off-by: leventecsanyi Issue-ID: CPS-475 Change-Id: I4b47ece82aed7e4b31aaa28e601e419fb6f06718 --- .../java/org/onap/cps/spi/CpsDataPersistenceService.java | 3 ++- .../src/main/java/org/onap/cps/spi/model/DataNode.java | 2 +- .../main/java/org/onap/cps/spi/model/DataNodeBuilder.java | 14 ++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'cps-service/src/main/java/org') diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java index 8d4df20b8..28b18b3b5 100644 --- a/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java +++ b/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java @@ -22,6 +22,7 @@ package org.onap.cps.spi; +import java.io.Serializable; import java.util.Collection; import java.util.List; import java.util.Map; @@ -97,7 +98,7 @@ public interface CpsDataPersistenceService { * @param xpath xpath * @param leaves the leaves as a map where key is a leaf name and a value is a leaf value */ - void updateDataLeaves(String dataspaceName, String anchorName, String xpath, Map leaves); + void updateDataLeaves(String dataspaceName, String anchorName, String xpath, Map leaves); /** * Replaces an existing data node's content including descendants. diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java b/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java index 8170db3da..76f33bbc1 100644 --- a/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java +++ b/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java @@ -46,7 +46,7 @@ public class DataNode implements Serializable { private ModuleReference moduleReference; private String xpath; private String moduleNamePrefix; - private Map leaves = Collections.emptyMap(); + private Map leaves = Collections.emptyMap(); private Collection xpathsChildren; private Collection childDataNodes = Collections.emptySet(); } diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java b/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java index eaa2d77f4..db7ef3e22 100644 --- a/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java +++ b/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java @@ -23,6 +23,7 @@ package org.onap.cps.spi.model; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import java.io.Serializable; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -48,7 +49,7 @@ public class DataNodeBuilder { private String xpath; private String moduleNamePrefix; private String parentNodeXpath = ""; - private Map leaves = Collections.emptyMap(); + private Map leaves = Collections.emptyMap(); private Collection childDataNodes = Collections.emptySet(); /** @@ -102,7 +103,7 @@ public class DataNodeBuilder { * @param leaves for the data node * @return DataNodeBuilder */ - public DataNodeBuilder withLeaves(final Map leaves) { + public DataNodeBuilder withLeaves(final Map leaves) { this.leaves = leaves; return this; } @@ -180,7 +181,7 @@ public class DataNodeBuilder { } else if (normalizedNode instanceof ValueNode) { final ValueNode valuesNode = (ValueNode) normalizedNode; addYangLeaf(currentDataNode, valuesNode.getIdentifier().getNodeType().getLocalName(), - valuesNode.body()); + (Serializable) valuesNode.body()); } else if (normalizedNode instanceof LeafSetNode) { addYangLeafList(currentDataNode, (LeafSetNode) normalizedNode); } else { @@ -199,8 +200,9 @@ public class DataNodeBuilder { } } - private static void addYangLeaf(final DataNode currentDataNode, final String leafName, final Object leafValue) { - final Map leaves = new ImmutableMap.Builder() + private static void addYangLeaf(final DataNode currentDataNode, final String leafName, + final Serializable leafValue) { + final Map leaves = new ImmutableMap.Builder() .putAll(currentDataNode.getLeaves()) .put(leafName, leafValue) .build(); @@ -213,7 +215,7 @@ public class DataNodeBuilder { .stream() .map(normalizedNode -> (normalizedNode).body()) .collect(Collectors.toUnmodifiableList()); - addYangLeaf(currentDataNode, leafListName, leafListValues); + addYangLeaf(currentDataNode, leafListName, (Serializable) leafListValues); } private static void addDataNodeForEachListElement(final DataNode currentDataNode, final MapNode mapNode) { -- cgit 1.2.3-korg