Completely understand the complexity. Let's talk through the use case at least and see if we can come to agreement on if it is something we think is useful -- even if we can't immediately see any good solutions.
Here's the use case in summary.
There are several APIs in the Java EE / Jakarta EE specifications that have the following injection rules for their annotations:
- Field injection: data is injected via annotations on fields of the class
- Setter injection: data is injected via annotations on setter methods
- Constructor injection: data is injected via annotations on parameters of a constructor
This means a lot of APIs have annotations that have a target type of FIELD, METHOD and PARAMETER. APIs that use this include CDI, JAXB, JSONB and JPA. JPA doesn't currently support constructor injection, but this is being discussed in Jakarta Persistence.
In the above, use of the annotations on Parameters are restricted to constructors. In the above, use of annotations on methods must be done on setters (methods with one parameter).
The use case is using Lombok to generate builders that are compliant with the above rules: annotations on a field are copied to the builder's "wither method"s so it can be used in the above APIs.
The trick is lombok will currently put any annotation that has PARAMETER as a target onto the parameter of the builder's "Wither param". This is true even if the annotation also targets METHOD. This means the builder cannot be used in the above APIs.
Do we think the above is a good use case?
-David
> To view this discussion on the web visit
https://groups.google.com/d/msgid/project-lombok/07e79db1-0f17-4634-9915-0f50a1575610n%40googlegroups.com.