itzhar
itzhar

Reputation: 13031

Custom Annotation with @StringDef for String array

i have the following code:

public static final String MY_CONSTANT_A = "A";
public static final String MY_CONSTANT_B = "B";

@StringDef(value={
        MY_CONSTANT_A,
        MY_CONSTANT_B
})
private @interface MyAnnotation{}

public static void someFunc(@MyAnnotation String str){

}

now when im trying to use string inside someFunc i got the next lint error as excepted:

enter image description here

now when i change my function to String ... str im not getting this lint error anymore.

public static void someFunc(@MyAnnotation String... str){

}

enter image description here

what is the way to do this?

Upvotes: 1

Views: 904

Answers (1)

Henry
Henry

Reputation: 17851

As far as I know, there is no Support annotation for Varargs and neither does StringDef does this. StringDef is just for String data type and does not extend to Varargs, yet.

The documentation has nothing on supporting Varargs: http://developer.android.com/reference/android/support/annotation/StringDef.html

Upvotes: 1

Related Questions