Open jlink opened 2 years ago
This is true... Maybe something like a @HookProximity annotation is the way to go in order to set it. If no hook is specified it could, by default set a proximity for all of them.... and if it can be set on both method and on the class it would allow for pretty great control.
It suddenly got a lot more complicated though :)
Testing Problem
Motivated by https://github.com/jlink/jqwik/issues/395 it would be useful to be able to specify the proximity of Lifecycle hooks not only at implementation time - through overriding the proximity method - but also at specification time. This would for example allow to influence the order in which lifecycle hooks are executed in regard to lifecycle methods (
@BeforeProperty
etc.)Suggested Solution
Implement attribute
proximity
toAddLifecycleHook
annotation which will translate the proximity to the hooks proximity.Discussion
This is not as straightforward as it sounds, because different hooks have different proximities. E.g.
AroundPropertyHook
has justaroundPropertyProximity()
andAroundContainerHook
has three different proximity values. Moreover, a single lifecycle hook implementation can implement more than one lifecycle hook. Therefore, a single attribute likeproximity
may not suffice.