diff options
author | Steve Smokowski <ss835w@att.com> | 2019-08-12 13:49:33 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-08-12 13:49:33 +0000 |
commit | c8b8b314536a33b55cadc304fee58572a6ac2938 (patch) | |
tree | ff21ec0ed03496a31380b4566ec19a7eef45c749 /common/src/main/java/org | |
parent | 268e86197979fe195742514a9add172b6db740f0 (diff) | |
parent | fd42ba68518d781fbf1dd8407acfb28f55ae490e (diff) |
Merge "query builder now handles more than just strings"
Diffstat (limited to 'common/src/main/java/org')
-rw-r--r-- | common/src/main/java/org/onap/so/client/graphinventory/entities/DSLNodeKey.java | 14 | ||||
-rw-r--r-- | common/src/main/java/org/onap/so/client/graphinventory/entities/__.java | 2 |
2 files changed, 10 insertions, 6 deletions
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLNodeKey.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLNodeKey.java index f7f5d78604..e301edb0fd 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLNodeKey.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLNodeKey.java @@ -32,9 +32,9 @@ public class DSLNodeKey implements QueryStep { private boolean not = false; private final StringBuilder query = new StringBuilder(); private final String keyName; - private final List<String> values; + private final List<Object> values; - public DSLNodeKey(String keyName, String... value) { + public DSLNodeKey(String keyName, Object... value) { this.keyName = keyName; this.values = Arrays.asList(value); @@ -54,14 +54,18 @@ public class DSLNodeKey implements QueryStep { result.append(" !"); } result.append("('").append(keyName).append("', "); - List<String> temp = new ArrayList<>(); - for (String item : values) { + List<Object> temp = new ArrayList<>(); + for (Object item : values) { if ("null".equals(item)) { temp.add(String.format("' %s '", item)); } else if ("".equals(item)) { temp.add("' '"); } else { - temp.add(String.format("'%s'", item)); + if (item instanceof String) { + temp.add(String.format("'%s'", item)); + } else { + temp.add(item); + } } } result.append(Joiner.on(", ").join(temp)).append(")"); diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/__.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/__.java index 2fdd6574e5..87d4d84cac 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/__.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/__.java @@ -45,7 +45,7 @@ public class __ { return __.<DSLNode>start(new DSLNode(name, key)); } - public static DSLNodeKey key(String keyName, String... value) { + public static DSLNodeKey key(String keyName, Object... value) { return new DSLNodeKey(keyName, value); } |