dnault / therapi-runtime-javadoc

Read Javadoc comments at run time.
Apache License 2.0
117 stars 19 forks source link

Implement enum constants #14

Closed skissane closed 6 years ago

skissane commented 6 years ago

I needed "enum constants" for a project so I implemented it.

I am submitting this pull request on behalf of my employer (Medallia Inc) who have approved its open sourcing under the Apache 2.0 license.

dnault commented 6 years ago

Thank you Simon. Sounds like a great enhancement. I'll take a detailed look as soon as possible.

dnault commented 6 years ago

Coincidentally, Joffrey Bion has submitted a PR that handles enum constants as well as other fields. Do you want to take a look and see if that API meets your requirements?

skissane commented 6 years ago

It is an unusual coincidence that we both implemented the same feature at the same time :)

I believe Joffrey's API will work for us, the point is I need to pass in an Enum instance and get its Javadoc back, and what Joffrey has done is basically the same–Joffrey's method returns a FieldJavadoc class instead of an EnumConstantJavadoc class but I can work with either.

Whether you want to have "FieldJavadoc" do the work of "EnumConstantJavadoc" or not I guess is a design issue you need to think about. Enum constants are physically fields, of course, but in a more logical sense they are different things, so how much do you want the API to reflect the physical vs logical reality? I was guided by the fact that javax.lang.model.element.ElementKind has two different values FIELD vs ENUM_CONSTANT, so based on that I was thinking each should be a different *Javadoc class. But it doesn't really matter.

(It was unfortunate that we had some internal confusion around our own open source policy–which we are working on clearing up–which delayed me getting approval to send you the pull request by a couple of weeks.)

Whatever you end up merging, I am looking forward to a release to Maven central so I can get rid of our internal fork of this project. (Which is basically just this pull request, plus some Gradle changes to push it to our internal Artifactory.)

dnault commented 6 years ago

Thanks for the thoughtful response. It's been a while and I owe you an update. The current plan is to move forward with PR #15 and to keep things simple by using FieldJavadoc for both types. As soon as it goes in I will push a 0.5.0 release to Maven Central.

dnault commented 6 years ago

Version 0.5.0 is released and available on Maven Central.

I believe Joffrey incorporated your unit tests into the final PR. Thank you!