包含字符串数组值的类型注释

时间:2017-07-26 08:43:25

标签: java

接口:

public @interface Types {
    String[] value();
}

声明:

@Types(TEST.T1, TEST.T2)
public class TEST{
    public static final String T1= "DAS";
    public static final String T2= "ABC";
}

如何正确地在类型界面中对属性进行分类?

1 个答案:

答案 0 :(得分:3)

你忘记了花括号:

public @interface Types {
    String[] value();
}

@Types({Test.T1, Test.T2}) // <- requires {} here because multiple values passed
public class Test{
    public static final String T1= "DAS";
    public static final String T2= "ABC";
}