14

I have a Annotation called

@Retention( RetentionPolicy.SOURCE )
@Target( ElementType.METHOD )
public @interface JIRA
{
    /**
     * The 'Key' (Bug number / JIRA reference) attribute of the JIRA issue.
     */
    String key();
}

which allows to add annotation like this

@JIRA( key = "JIRA1" )

is there any way to allow this to happen

@JIRA( key = "JIRA1", "JIRA2", .....  )

the reason is, we currently annotate the test against a Jira task or bug fix, but sometimes, then the value will get parsed by sonar. problem is a single test covers more then 1 bug.

Junchen Liu
  • 5,435
  • 10
  • 51
  • 62

1 Answers1

18

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"})
Amit Deshpande
  • 19,001
  • 4
  • 46
  • 72