为什么 getAnnotation(Parsed.class).field() returning String[]?(它应该是 return 字符串,因为它将输入作为字符串)

Why getAnnotation(Parsed.class).field() returning String[]?(It should return String, as it is taking input as String)

我有以下代码。

import com.univocity.parsers.annotations.Parsed;
import org.apache.commons.lang3.reflect.FieldUtils;
import java.lang.reflect.Field;

public class MyClass {
    public static void main(String args[]) {
        try{
            for (Field field : FieldUtils.getAllFieldsList(SpendsInputBean.class)) {
                String[] headerName = field.getAnnotation(Parsed.class).field();
//              ^
//              |____________(Shouldn't this be String)


                .
                .
                .
            }
        }catch(Exception ex){
            System.out.println(ex);
        }
    }
}

class X {
    @Parsed(field = "Abc")
    private String abc;
}

我的问题是Parsed(field = "Abc"),这里的字段以String作为输入。但是当我 getAnnotation(Parsed.class).field() 时,它是 returning String[] 而不是 String。为什么会有这种奇怪的行为?

不应该getAnnotation(Parsed.class).field()returnString吗?

根据 UniVocity github 回购:

https://github.com/uniVocity/univocity-parsers/blob/master/src/main/java/com/univocity/parsers/annotations/Parsed.java

只有 1 个方法 field() 的 return 类型是 String[] 而不是 String

 String[] field() default {};  

编辑:

对于问题的第二部分,即为什么允许 Parsed(field = "Abc") - 这是因为:

If the element type is an array type, then it is not required to use curly braces to specify the element value of the element-value pair

我引用了this doc which you can refer. Additional reference : 的上述说法。