Reputation: 35
Is this possible to get an int array in a custom annotation?
If yes, how to I call it?
Here's a dummy example to help me understand... Suppose that I have @Add() that takes an infinite number of operand.
@Add(operand1=10, operand2=20, operandx=...)
What I want is to have only one property operands.
Upvotes: 1
Views: 528
Reputation: 120958
You can achieve what you want if you add a parameter to the interface as an array.
public @interface Add {
int [] operands();
}
Then usage would be :
@Add(operands={1,2,3})
Note: var-args would not work; the compiler will reject it.
Upvotes: 3