On Mon, 31 Oct 2022 13:02:18 GMT, Jim Laskey <jlas...@openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/template/StringTemplate.java line 149:
>> 
>>> 147:      * {@return the interpolation of the StringTemplate}
>>> 148:      */
>>> 149:     default String interpolate() {
>> 
>> I wonder if all the default methods should not be better as static methods 
>> given that they are not the important part of the API but more side 
>> information that may be handy
>
> Actually instance interpolate() is the most important method. Each synthetic 
> StringTemplate gets a specialized interpolate providing performance 
> equivalent to string concat. And, a good percentage  of processors will work 
> with the result of interpolate to produce result. Ex. `StringProcessor STR = 
> st -> st.interpolate();` and`TemplateProcessor<JSONObject> JSON = st -> new 
> JSONObject(st.interpolate());`

Interesting !
I believe the javadoc should mention that.

-------------

PR: https://git.openjdk.org/jdk/pull/10889

Reply via email to