1

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.