On Mon, 24 Jan 2022 19:59:59 GMT, Jonathan Gibbons <j...@openjdk.org> wrote:

>> src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java
>>  line 240:
>> 
>>> 238:         list.forEach(item -> add(mapper.apply(item)));
>>> 239:         return this;
>>> 240:     }
>> 
>> We could move this implementation of `addAll` to the `Content` base class as 
>> it is except for changing the return type to `Content`. This would make the 
>> method available in other subclasses that override/support `add(Content)`, 
>> such as `ContentBuilder`. The only observable change would be that it 
>> wouldn't throw `UnsupportedOperationException` when called with an empty 
>> collection in non-addable classes.  I think that's an acceptable behaviour 
>> for an internal API.
>
> Another observable change would be that the method could not be used in 
> method chaining, because of the different return type.  But having the method 
> applicable at least in a limited form in ContentBuilder would be nice, but 
> that suggests leaving a covariant override here.

Another reason to make a minor update ... the doc comment on the method in 
Content is incorrect ... the `@implSpec` is wrong.

I'll copy (not move) the implementation from `HtmlTree` to `Content`.

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

PR: https://git.openjdk.java.net/jdk/pull/7166

Reply via email to