Is it possible to use Lombok annotations as a meta-annotation?

两盒软妹~` 提交于 2020-04-29 09:01:23

问题


I want to define my own annotation for transfer objects and include there some Lombok annotations as meta-annotations:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@Data
@NoArgsConstructor
@AllArgsConstructor
public @interface TransferObject {
}

The intent is to annotate all my transfer objects with @TransferObject and "inherit" all of the above. In practice it doesn't work, classes annotated with @TransferObject are not processed by Lombok.

Is there some way to get this working? If not, it it theoretically possible to enhance Lombok to look for meta-annotations?

Note: I'm on Java 8.

UPDATE: It looks like there's a feature request for this on github.


回答1:


Short answer is NOT (for current version 1.18.4 - Oct 30, 2018)

According to the thread here:

This feature would require resolution in a very early stage of processing. Currently that is not possible. Possibly, since we now have the lombok configuration system, we might come up with a different solution.

Actually, they have several requests of the similar functionality on Lombok's GitHub page - non of them is implemented.

Please consider upvoting this feature or this one.



来源:https://stackoverflow.com/questions/33512957/is-it-possible-to-use-lombok-annotations-as-a-meta-annotation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!