Ability to list a method in the Constructors summary
Nir Lisker
nlisker at gmail.com
Tue Oct 2 13:54:14 UTC 2018
Hi,
Many static methods are used to obtain an instance of a class, functioning
as a de-facto constructor and sometimes replacing it altogether. These are
factory or builder methods and the like.
The problem is that while they function as constructors, they are hidden
between the rest of the methods in the JavaDoc. It is my understanding that
the Constructors section shows how to create an instance, while the Methods
section shows how to use it. In this case, the aforementioned methods will
fit better in the Constructors section.
One way this can be solved is via an annotation on the method that would
list it under the Constructors, used at the developers discretion. As an
example, Toolkit is a singleton:
public class Toolkit {
private final Toolkit TOOLKIT;
private Toolkit() { ... }
@Constructor
public static getDefaultSystemToolkit() { return TOOLKIT; }
}
The annotation shows the intended way for a developer to obtain the
instance.
I can submit an RFE if this is plausible. Otherwise, I'm open for other
solutions if you agree with the problem I presented.
- Nir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/javadoc-dev/attachments/20181002/c0c6233a/attachment.html>
More information about the javadoc-dev
mailing list