aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2017-08-30 05:56:17 -0700
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2017-08-30 05:56:17 -0700
commit0b34dfecd6ee4e7f887fa47d2181edf097de788d (patch)
tree1c8adc83ece008a7fc91e4e1285f7b21d28388d9 /src
parentdba8d74ffafc51cdd496099d5ad0f391a234e402 (diff)
Fix Sonar bugs
In ModelElement.class Blocker issues fixed Change-Id: Ia03757ed3675d6af8a65b9ed862db25e703387d6 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java133
1 files changed, 67 insertions, 66 deletions
diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java
index 42333559e..42d11f4b5 100644
--- a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java
+++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java
@@ -23,32 +23,32 @@
package org.onap.clamp.clds.model.prop;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.fasterxml.jackson.databind.JsonNode;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
/**
* Provide base ModelElement functionality.
*/
public abstract class ModelElement {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelElement.class);
+ protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelElement.class);
protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
- public static final String TYPE_POLICY = "policy";
- public static final String TYPE_TCA = "tca";
+ public static final String TYPE_POLICY = "policy";
+ public static final String TYPE_TCA = "tca";
- private final String type;
- private final ModelBpmn modelBpmn;
- private final String id;
- protected String topicPublishes;
- protected final JsonNode meNode;
- private boolean isFound;
+ private final String type;
+ private final ModelBpmn modelBpmn;
+ private final String id;
+ protected String topicPublishes;
+ protected final JsonNode meNode;
+ private boolean isFound;
- private final ModelProperties modelProp;
+ private final ModelProperties modelProp;
/**
* Perform base parsing of properties for a ModelElement (such as,
@@ -122,57 +122,58 @@ public abstract class ModelElement {
}
return value;
}
-
- /**
- * Return the value field of the json node element that has a name field that equals the given name.
- *
- * @param nodeIn
- * @param name
- * @return
- */
- public static String getNodeValueByName(JsonNode nodeIn, String name) {
- String value = null;
- if ( nodeIn != null ) {
- value = nodeIn.path(name).asText();
- }
- if ( value == null || value.length() == 0 ) {
- logger.warn(name + "=" + value);
- } else {
- logger.debug(name + "=" + value);
- }
- return value;
- }
-
-
- /**
- * Return the value field of the json node element that has a name field that equals the given name.
- *
- * @param nodeIn
- * @param name
- * @return
- */
- public static List<String> getNodeValuesByName(JsonNode nodeIn, String name) {
- List<String> values = new ArrayList<String>();
- if ( nodeIn != null ) {
- Iterator<JsonNode> i = nodeIn.iterator();
- while (i.hasNext()) {
- JsonNode node = i.next();
- if ( node.path("name").asText().equals(name) ) {
- String value = "";
- JsonNode vnode = node.path("value");
- if ( vnode.isArray() ) {
- // if array, assume value is in first element
- value = vnode.path(0).asText();
- } else {
- // otherwise, just return text
- value = vnode.asText();
- }
- values.add(value);
- }
- }
- }
- return values;
- }
+
+ /**
+ * Return the value field of the json node element that has a name field
+ * that equals the given name.
+ *
+ * @param nodeIn
+ * @param name
+ * @return
+ */
+ public static String getNodeValueByName(JsonNode nodeIn, String name) {
+ String value = null;
+ if (nodeIn != null) {
+ value = nodeIn.path(name).asText();
+ }
+ if (value == null || value.length() == 0) {
+ logger.warn(name + "=" + value);
+ } else {
+ logger.debug(name + "=" + value);
+ }
+ return value;
+ }
+
+ /**
+ * Return the value field of the json node element that has a name field
+ * that equals the given name.
+ *
+ * @param nodeIn
+ * @param name
+ * @return
+ */
+ public static List<String> getNodeValuesByName(JsonNode nodeIn, String name) {
+ List<String> values = new ArrayList<>();
+ if (nodeIn != null) {
+ Iterator<JsonNode> i = nodeIn.iterator();
+ while (i.hasNext()) {
+ JsonNode node = i.next();
+ if (node.path("name").asText().equals(name)) {
+ String value;
+ JsonNode vnode = node.path("value");
+ if (vnode.isArray()) {
+ // if array, assume value is in first element
+ value = vnode.path(0).asText();
+ } else {
+ // otherwise, just return text
+ value = vnode.asText();
+ }
+ values.add(value);
+ }
+ }
+ }
+ return values;
+ }
/**
* Return the int value field of the json node element that has a name field
@@ -206,7 +207,7 @@ public abstract class ModelElement {
}
}
}
- if (values == null || values.size() == 0) {
+ if (values == null || values.isEmpty()) {
logger.warn(name + "=" + values);
} else {
logger.debug(name + "=" + values);