how to create a single annotation accept multiple values in Java

后端 未结 1 1227
情话喂你
情话喂你 2021-02-13 15:18

I have a Annotation called

@Retention( RetentionPolicy.SOURCE )
@Target( ElementType.METHOD )
public @interface JIRA
{
    /**
     * The \'Key\' (Bug number /          


        
相关标签:
1条回答
  • 2021-02-13 15:32

    Change your key() function to return String[] rather than String then you can pass various values using String[]

    public @interface JIRA {
    /**
     * The 'Key' (Bug number / JIRA reference) attribute of the JIRA issue.
     */
    String[] key();
    }
    

    Use it like below

    @JIRA(key = {"JIRA1", "JIRA2"})
    
    0 讨论(0)
提交回复
热议问题