2 Replies Latest reply on Dec 12, 2016 6:38 PM by ljnelson

    Qualifier has only FIELD and PARAMETER: need to write a producer method

    ljnelson

      I am sure I am missing some insert-tab-A-into-slot-B recipe here.

       

      I am working with a non-modifiable Qualifier annotation named Fred.  Its Targets are only PARAMETER and FIELD.  I cannot alter this annotation in any way.  But I want to process this annotation using custom logic, so I want to write a producer method that can "fill" "slots" that are annotated with Fred.

       

      I would like (in the abstract) to write a producer method that can work with this Qualifier, i.e. something that would let me do:

      @Produces @Fred // this is actually not possible, because Fred can (as written) only apply to FIELDs and PARAMETERs public Frob getFrob() {   return new FredFrobImpl(); }

      Of course, because its Targets don't permit me to annotate my producer method with Fred, this is not straightforward.

       

      I can programmatically futz with the Fred Qualifier itself in a portable extension, and alter its Target meta-annotation.  But that doesn't do me any good with my producer method (see above): I still cannot annotate it with Fred because of course at compilation time this is invalid.

       

      What is the design pattern others use here, since of course this is not a particularly strange use case?