From 28c3abf558b0697f063e792fc08e1b1b0a9c561b Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Thu, 20 Dec 2018 13:08:04 +0530 Subject: fixed sonar issues in PrintYangToProp.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: Ifb7328c8b3cf40d412a0efffad6cb55673cf83dc Signed-off-by: Sandeep J --- .../org/onap/ccsdk/sli/core/sli/PrintYangToProp.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java index 86135210..3e8983bb 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java @@ -48,6 +48,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.base.Strings; public class PrintYangToProp { @@ -144,8 +145,8 @@ public class PrintYangToProp { fieldName = toLowerHyphen(m.getName().substring(2)); } - if(fieldName!= null && fieldName.length() >0 ) fieldName = fieldName.substring(0, 1).toLowerCase() - + fieldName.substring(1); + if(Strings.isNullOrEmpty(fieldName)) fieldName = fieldName.substring(0, 1).toLowerCase()+ fieldName.substring(1); + // Is the return type a yang generated class? if (isYangGenerated(returnType)) { @@ -196,8 +197,7 @@ public class PrintYangToProp { if (retValue != null) { String propVal = retValue.getValue(); - //LOG.debug("Setting property " + propName - // + " to " + propVal); + props.setProperty(propName, propVal); } @@ -223,8 +223,7 @@ public class PrintYangToProp { if (retValue != null) { String propVal = retValue.getValue(); - //LOG.debug("Setting property " + propName - // + " to " + propVal); + props.setProperty(propName, propVal); } @@ -236,7 +235,7 @@ public class PrintYangToProp { + TO_PROPERTIES_STRING, e); } } else if (isIpv4Prefix(returnType)) { - //System.out.println("isIpv4Prefix"); + // Save its value try { String propName = propNamePfx + "." + fieldName; @@ -250,9 +249,8 @@ public class PrintYangToProp { } if (retValue != null) { - String propVal = retValue.getValue().toString(); - //LOG.debug("Setting property " + propName - // + " to " + propVal); + String propVal = retValue.getValue(); + props.setProperty(propName, propVal); } -- cgit 1.2.3-korg