OfficeScenarioTests CoopShares+Assets #121
@ -22,25 +22,25 @@ public class TemplateResolver {
|
|||||||
enum PlaceholderPrefix {
|
enum PlaceholderPrefix {
|
||||||
RAW('%') {
|
RAW('%') {
|
||||||
@Override
|
@Override
|
||||||
String convert(final String value, final Resolver resolver) {
|
String convert(final Object value, final Resolver resolver) {
|
||||||
return value != null ? value.toString() : "";
|
return value != null ? value.toString() : "";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
JSON_QUOTED('$'){
|
JSON_QUOTED('$'){
|
||||||
@Override
|
@Override
|
||||||
String convert(final String value, final Resolver resolver) {
|
String convert(final Object value, final Resolver resolver) {
|
||||||
return jsonQuoted(value);
|
return jsonQuoted(value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
URI_ENCODED('&'){
|
URI_ENCODED('&'){
|
||||||
@Override
|
@Override
|
||||||
String convert(final String value, final Resolver resolver) {
|
String convert(final Object value, final Resolver resolver) {
|
||||||
return value != null ? URLEncoder.encode(value.toString(), StandardCharsets.UTF_8) : "";
|
return value != null ? URLEncoder.encode(value.toString(), StandardCharsets.UTF_8) : "";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
COMMENT('#'){
|
COMMENT('#'){
|
||||||
@Override
|
@Override
|
||||||
String convert(final String value, final Resolver resolver) {
|
String convert(final Object value, final Resolver resolver) {
|
||||||
return resolver == DROP_COMMENTS ? "" : value.toString();
|
return resolver == DROP_COMMENTS ? "" : value.toString();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -59,7 +59,7 @@ public class TemplateResolver {
|
|||||||
return Arrays.stream(values()).filter(p -> p.prefixChar == givenChar).findFirst().orElseThrow();
|
return Arrays.stream(values()).filter(p -> p.prefixChar == givenChar).findFirst().orElseThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract String convert(final String value, final Resolver resolver); // FIXME: why Object and not String?
|
abstract String convert(final Object value, final Resolver resolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Pattern pattern = Pattern.compile(",(\\s*})", Pattern.MULTILINE);
|
private final static Pattern pattern = Pattern.compile(",(\\s*})", Pattern.MULTILINE);
|
||||||
hsh-michaelhoennig marked this conversation as resolved
Outdated
|
|||||||
@ -136,7 +136,7 @@ public class TemplateResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final var content = new TemplateResolver(placeholder.toString(), properties).resolve(resolver);
|
final var content = new TemplateResolver(placeholder.toString(), properties).resolve(resolver);
|
||||||
final var value = intro != '#' ? propVal(content).toString() : content;
|
final var value = intro != '#' ? propVal(content) : content;
|
||||||
resolved.append(
|
resolved.append(
|
||||||
PlaceholderPrefix.ofPrefixChar(intro).convert(value, resolver)
|
PlaceholderPrefix.ofPrefixChar(intro).convert(value, resolver)
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user
nur }?