|
47 | 47 | import java.util.Collection;
|
48 | 48 | import java.util.List;
|
49 | 49 | import java.util.Map;
|
| 50 | +import java.util.Objects; |
50 | 51 | import java.util.Set;
|
51 | 52 |
|
52 | 53 | /**
|
@@ -74,21 +75,28 @@ public void endVisit(JPermutationDependentValue x, Context ctx) {
|
74 | 75 | }
|
75 | 76 |
|
76 | 77 | private JExpression propertyValueExpression(JPermutationDependentValue x) {
|
77 |
| - List<String> propertyValues = props.getConfigurationProperties().getStrings(x.getRequestedValue()); |
78 |
| - |
79 |
| - String propertyValue = propertyValues.isEmpty() ? null : Joiner.on(",").join(propertyValues); |
80 |
| - |
81 |
| - if (propertyValue != null) { |
| 78 | + List<String> propertyValues = props.getConfigurationProperties() |
| 79 | + .getStringsOrNull(x.getRequestedValue()); |
| 80 | + if (propertyValues != null) { |
82 | 81 | // It is a configuration property.
|
83 |
| - return program.getLiteral(x.getSourceInfo(), propertyValue); |
| 82 | + // If no values are set, propertyValues is either empty (multivalued properties) |
| 83 | + // or contains a single null (other properties). |
| 84 | + if (propertyValues.stream().anyMatch(Objects::nonNull)) { |
| 85 | + return program.getLiteral(x.getSourceInfo(), |
| 86 | + Joiner.on(",").skipNulls().join(propertyValues)); |
| 87 | + } |
| 88 | + if (x.getDefaultValueExpression() != null) { |
| 89 | + return x.getDefaultValueExpression(); |
| 90 | + } |
| 91 | + return program.getLiteralNull(); |
84 | 92 | }
|
85 | 93 |
|
86 | 94 | if (isSoftPermutationProperty(x.getRequestedValue())) {
|
87 | 95 | JMethod method = getOrCreateSoftPropertyMethod(x.getSourceInfo(), x.getRequestedValue());
|
88 | 96 | return new JMethodCall(x.getSourceInfo(), null, method);
|
89 | 97 | }
|
90 | 98 |
|
91 |
| - propertyValue = commonPropertyAndBindingInfo.getPropertyValue(x.getRequestedValue()); |
| 99 | + String propertyValue = commonPropertyAndBindingInfo.getPropertyValue(x.getRequestedValue()); |
92 | 100 |
|
93 | 101 | if (propertyValue != null) {
|
94 | 102 | return program.getLiteral(x.getSourceInfo(), propertyValue);
|
|
0 commit comments