On Thu, 23 Mar 2023 12:12:36 GMT, Jim Laskey <jlas...@openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/StringTemplate.java line 679: >> >>> 677: @PreviewFeature(feature=PreviewFeature.Feature.STRING_TEMPLATES) >>> 678: @FunctionalInterface >>> 679: public interface StringProcessor extends SimpleProcessor<String> { >> >> Just curious, what's the rationale of a `SimpleProcessor` or >> `StringProcessor` as opposed to: >> >> static <T> TemplateProcessor<T, RuntimeException> >> simple(Function<StringTemplate, T> function) {...} >> static TemplateProcessor<String, RuntimeException> >> string(Function<StringTemplate, String> function) {...} >> >> which avoids the requirement of specifying the type of the template >> processor local variable; users can use `var` instead. > > Worth considering. Thank you. You can, of course, reduce this to; interface Processor { ... static <T> StringTemplate.Processor<T, RuntimeException> of(Function<StringTemplate, T> function) { return function::apply; } ... } since String is just a type. This proposal has merit and worth some thought. -2 interfaces, +1 method. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/10889#discussion_r1146303119