问题
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