简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM