mercredi 13 juin 2018

Can I pass a class literal from a templated class as an argument for an annotation?

I have an annotation that takes a Class as value (the response field of @ApiResponse from springfox). The response I want mapped is a templated class (PageDTO<T>) but I can not get a class literal for my specific entity, e.g. PageDTO<BusinessClass>.class. The only option that works is defining another class: class Doc extends PageDTO<BusinessClass> and pass the value of Doc.class as parameter.

Is there a way of achieving the same result without defining a class for each annotated method?

I tried the double casting method, (Class<PageDto<BusinessClass>>)(Class<?>)PageDTO.class but it did not work.





Aucun commentaire:

Enregistrer un commentaire