blob: 9ee8526c7b4473cbd7dc2627bfda7471369b3d45 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package org.onap.so.client.aai.entities;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.google.common.base.Joiner;
public class DSLNodeKey implements QueryStep {
private boolean not = false;
private final StringBuilder query = new StringBuilder();
private final String keyName;
private final List<String> values;
public DSLNodeKey(String keyName, String... value) {
this.keyName = keyName;
this.values = Arrays.asList(value);
}
public DSLNodeKey not() {
this.not = true;
return this;
}
@Override
public String build() {
if (not) {
query.append(" !");
}
query.append("('").append(keyName).append("', ");
List<String> temp = new ArrayList<>();
for (String item : values) {
if (item.equals("null")) {
temp.add(String.format("' %s '", item));
} else if (item.equals("")){
temp.add("' '");
} else {
temp.add(String.format("'%s'", item));
}
}
query.append(Joiner.on(", ").join(temp)).append(")");
return query.toString();
}
}
|