diff options
author | Rishi Chail <rishi.chail@est.tech> | 2021-04-26 16:05:35 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-04-26 16:05:35 +0000 |
commit | 4403e852c0a519bb9edc8a1b467bf2a9af5f9eb2 (patch) | |
tree | 2f12f67326e1fb071c8e594dfd0a9b39ae984701 /cps-ri/src/main | |
parent | 8895ce4bc508874e95321f97acc014f5e5be7fa7 (diff) | |
parent | 0d8464363d70fa470c048bb4cd1f24a9e79d7cce (diff) |
Merge "Leaf String value comparison matches mix of single and double quotes"
Diffstat (limited to 'cps-ri/src/main')
-rw-r--r-- | cps-ri/src/main/java/org/onap/cps/spi/query/CpsPathQuery.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/query/CpsPathQuery.java b/cps-ri/src/main/java/org/onap/cps/spi/query/CpsPathQuery.java index c5861bd4b6..ac7e7e0ac3 100644 --- a/cps-ri/src/main/java/org/onap/cps/spi/query/CpsPathQuery.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/query/CpsPathQuery.java @@ -52,7 +52,8 @@ public class CpsPathQuery { private static final Pattern LEAF_INTEGER_VALUE_PATTERN = Pattern.compile("[-+]?\\d+"); - private static final Pattern LEAF_STRING_VALUE_PATTERN = Pattern.compile("['\"](.*)['\"]"); + private static final Pattern LEAF_STRING_VALUE_IN_SINGLE_QUOTES_PATTERN = Pattern.compile("'(.*)'"); + private static final Pattern LEAF_STRING_VALUE_IN_DOUBLE_QUOTES_PATTERN = Pattern.compile("\"(.*)\""); private static final String YANG_MULTIPLE_LEAF_VALUE_EQUALS_CONDITION = "\\[(.*?)\\s{0,9}]"; @@ -118,9 +119,15 @@ public class CpsPathQuery { } private static Object convertLeafValueToCorrectType(final String leafValueString, final String cpsPath) { - final Matcher stringValueWithQuotesMatcher = LEAF_STRING_VALUE_PATTERN.matcher(leafValueString); - if (stringValueWithQuotesMatcher.matches()) { - return stringValueWithQuotesMatcher.group(1); + final Matcher stringValueWithSingleQuotesMatcher = + LEAF_STRING_VALUE_IN_SINGLE_QUOTES_PATTERN.matcher(leafValueString); + if (stringValueWithSingleQuotesMatcher.matches()) { + return stringValueWithSingleQuotesMatcher.group(1); + } + final Matcher stringValueWithDoubleQuotesMatcher = + LEAF_STRING_VALUE_IN_DOUBLE_QUOTES_PATTERN.matcher(leafValueString); + if (stringValueWithDoubleQuotesMatcher.matches()) { + return stringValueWithDoubleQuotesMatcher.group(1); } final Matcher integerValueMatcher = LEAF_INTEGER_VALUE_PATTERN.matcher(leafValueString); if (integerValueMatcher.matches()) { |