简体   繁体   English

带有或不带有参数的Java 6注释重复

[英]Java 6 Annotations Repeating with or without parameter

I have the following annotation: 我有以下注释:

public @interface ExcludeVariable {
    String list();
}

I want to be able preprocessing this in two different ways 我希望能够以两种不同的方式对此进行预处理

First: 第一:

@ExcludeVariable // without parameter
int a;

Second: 第二:

@ExcludeVariable(list="a,b") // with parameter
public void test(){
     int a;
     int b;
     int c;
}

In Java 8 there is an option to "repeat" annotations 在Java 8中,有一个选项可以“重复”注释

http://docs.oracle.com/javase/tutorial/java/annotations/repeating.html http://docs.oracle.com/javase/tutorial/java/annotations/repeating.html

How to handle this in Java 6 如何在Java 6中处理此问题

Best regards 最好的祝福

Use "default". 默认情况下使用”。 Read more here 在这里阅读更多

public @interface ExcludeVariable {
    String list() default "";
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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