AuthMe / ConfigMe

A simple configuration management library for any Java project!
MIT License
37 stars 14 forks source link

Throw if @Comment and registerComments use the same path for a comment #342

Closed ljacqu closed 1 year ago

ljacqu commented 1 year ago

Currently, if @Comment on a property and some statement in SettingsHolder#registerComments set the comments for the same path, one of the comments is just discarded. This is misleading, and should be prevented by throwing an exception. There's no use case to defining part of the comment in the annotation or in the method—one approach should be used per path.

To do

Hint

sharief007 commented 1 year ago

We can use Map#containsKey to check if the path is already mapped to a list of comments before throwing the exception. However, this approach may not allow us to overwrite an existing path. It seems the CommentsConfiguration#setComment should allow overriding the paths. Hence as mentioned in the issue description Map#put is used to check.

Pull Request: https://github.com/AuthMe/ConfigMe/pull/373