diff options
author | Timoney, Dan (dt5972) <dt5972@att.com> | 2018-07-12 12:29:42 -0400 |
---|---|---|
committer | Timoney, Dan (dt5972) <dt5972@att.com> | 2018-07-12 12:29:42 -0400 |
commit | cfabda23cb6dc6c98e3266228f3bd2f409591a2f (patch) | |
tree | 51b0a45b9545e4af05738a12232e359e2b17c217 | |
parent | 7636bbc1db457a7cff570b35c724e4253d0a1cd4 (diff) |
Special handling for inet classes
Add special handling for inet POJOs (which have different form
then POJOs generated from Yang by yangtools) in toList method.
Change-Id: Ie25527e6aacbf683965d7f24018fe066c74fb917
Issue-ID: CCSDK-362
Signed-off-by: Timoney, Dan (dt5972) <dt5972@att.com>
-rw-r--r-- | sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java | 66 |
1 files changed, 51 insertions, 15 deletions
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index b652c433c..e50b99742 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -528,24 +528,60 @@ public class MdsalHelper { String curBase = pfx + "[" + i + "]"; if (isYangGenerated(elemType)) { - String builderName = elemType.getName() + "Builder"; - try { - Class builderClass = Class.forName(builderName); - Object builderObj = builderClass.newInstance(); - Method buildMethod = builderClass.getMethod("build"); - builderObj = toBuilder(props, curBase, builderObj, true); - if (builderObj != null) { - LOG.trace("Calling " + builderObj.getClass().getName() + "." + buildMethod.getName() + "()"); - Object builtObj = buildMethod.invoke(builderObj); - toObj.add(builtObj); + + if (isIpAddress(elemType) || isIpv4Address(elemType) || isIpv6Address(elemType)) { + + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(IpAddressBuilder.getDefaultInstance(curValue)); foundValue = true; } + } else if (isIpPrefix(elemType)) { - } catch (ClassNotFoundException e) { - LOG.warn("Could not find builder class {}", builderName, e); - } catch (Exception e) { - LOG.error("Caught exception trying to populate list from {}", pfx, e); - } + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(IpPrefixBuilder.getDefaultInstance(curValue)); + foundValue = true; + } + } else if (isPortNumber(elemType)) { + + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(PortNumber.getDefaultInstance(curValue)); + foundValue = true; + } + } else if (isDscp(elemType)) { + + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(Dscp.getDefaultInstance(curValue)); + foundValue = true; + } + } else { + String builderName = elemType.getName() + "Builder"; + try { + Class builderClass = Class.forName(builderName); + Object builderObj = builderClass.newInstance(); + Method buildMethod = builderClass.getMethod("build"); + builderObj = toBuilder(props, curBase, builderObj, true); + if (builderObj != null) { + LOG.trace( + "Calling " + builderObj.getClass().getName() + "." + buildMethod.getName() + "()"); + Object builtObj = buildMethod.invoke(builderObj); + toObj.add(builtObj); + foundValue = true; + } + + } catch (ClassNotFoundException e) { + LOG.warn("Could not find builder class {}", builderName, e); + } catch (Exception e) { + LOG.error("Caught exception trying to populate list from {}", pfx, e); + } + } } else { // Must be a leaf list String curValue = props.getProperty(curBase, ""); |