FabLabsMC / fiber

A configuration system. Maintained by @zeroeightysix and @Pyrofab
Apache License 2.0
32 stars 8 forks source link

Allow users to modify which fields of a class are processed by the annotation processor #53

Closed zeroeightysix closed 4 years ago

zeroeightysix commented 4 years ago

This PR adds an interface MemberCollector which is in charge of collecting the set of fields or methods from a Class<?> that will be processed by AnnotatedSettings.

This allows AnnotatedSettings to also look at the fields in superclasses, or allows users to artificially ignore fields. It may be useful to avoid repetition in config POJOs (think of e.g. a list of modules that all have an 'enabled' property).

Another thought is to also offload the logic for ignoring fields/methods to the MemberCollector. This way we can extend the recursive MemberCollector to also look at @Settings annotations on superclasses.

Pyrofab commented 4 years ago

I think it would be a good idea to do the transient and Ignored checks in this class. Would remove some hardcoding in AnnotatedSettings.

Pyrofab commented 4 years ago

Is it really useful to make a subpackage for just 2 new classes ? I think MemberCollector could go in the base annotation package, while SettingProcessor could go to the existing processor subpackage. Maybe SettingProcessor could be renamed too ? Something like PojoMemberProcessor ?

zeroeightysix commented 4 years ago

Generally, I try to organise features per-package, and in this case not to clutter the io.github.fablabsmc.fablabs.api.fiber.v1.annotation package with unrelated classes. If you feel strongly about not keeping it this way, feel free to change it however.

PojoMemberProcessor probably does describe the class better.