Extension to infer type (generics params) of class #4420
-
Would it be possible to somehow write extension that automatically infers type of class (generics parameters) from annotation or naming convention. Yet again this is motivated by need to improve type checks in large codebase (hundreds of classes) without need to manually write generics annotations for each of them. Basically I want interpret: /**
* @mapperEntity User
*/
class UserMapper extends Mapper as: /**
* @mapperEntity User
* @extends Mapper<User, UserCollection>
*/
class UserMapper extends Mapper Is it possible? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Not directly, but it depends on what the first type variable of Again, the best course of action is to generate the |
Beta Was this translation helpful? Give feedback.
Not directly, but it depends on what the first type variable of
Mapper
does inMapper
. If you simply have@return T
somewhere inMapper
that maps to@return User
inUserMapper
, then you can write a dynamic return type extension for that.Again, the best course of action is to generate the
@extends
. It's achievable with a simple search+replace.