blob: 5f037a6147db170e28eb1f7715dbc594d111ed4b (
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
50
51
52
53
54
|
package org.onap.sdc.dcae.composition.restmodels.ruleeditor;
import java.util.List;
import java.util.stream.Stream;
public class Condition extends BaseCondition {
protected String left;
protected String operator;
protected List<String> right;
public String getLeft() {
return left;
}
public void setLeft(String left) {
this.left = left;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public List<String> getRight() {
return right;
}
public void setRight(List<String> right) {
this.right = right;
}
@Override
public boolean referencesTarget(String target) {
return Stream.concat(Stream.of(left), right.stream())
.filter(this::isReference)
.map(this::strippedReference)
.anyMatch(target::equals);
}
private String strippedReference(String value) {
return value.substring(2, value.length()-1);
}
private boolean isReference(String value) {
return value.startsWith("${") && value.endsWith("}");
}
}
|