RFR: JDK-8280402: Add new convenience forms to HtmlTree
Jonathan Gibbons
jjg at openjdk.java.net
Mon Jan 24 20:03:05 UTC 2022
On Fri, 21 Jan 2022 09:58:14 GMT, Hannes Wallnöfer <hannesw at openjdk.org> wrote:
>> Please review a simple `noreg-clean` update to `HtmlTree` and a couple of friends. The updates are to continue the trend towards the use of Facebook tory methods for `HtmlTree` objects, and to leverage generic methods and lambdas to generate composite content. The cleanup is mostly extracted from some parallel work for a separate PR. Some of the more general cleanup was suggested by an IDE.
>>
>> All javadoc tests pass locally; I have a job in progress to validate the fix on all platforms, although there is no reason to believe there might be any issues.
>
> 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.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7166
More information about the javadoc-dev
mailing list