Is there a way to set one "//$NON-NLS" annotation for all Strings in one line?

1.3k Views Asked by At

does anybody know if it is possible to set one //$NON-NLS annotation tag in java for all Strings in one line... maybe like this:

String[][] info = new String[][]{
     {"a1", "a2"}, {"b1", "b2"}, {"c1", "c2"}, {"d1", "d2"} //$NON-NLS-ALL$
};       

I like to prevent this long line of code:

String[][] info = new String[][]{
     {"a1", "a2"}, {"b1", "b2"}, {"c1", "c2"}, {"d1", "d2"} //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
};

thanks

2

There are 2 best solutions below

1
On

You can instruct to ignore all by adding //$NON-NLS-L$

1
On

I don't think you can make this work with the //$NON-NLS comments, but you can suppress the NLS warnings for the whole variable declaration:

@SuppressWarnings("nls")
String[][] info = new String[][] {
    {"a1", "a2"}, {"b1", "b2"}, {"c1", "c2"}, {"d1", "d2"}
};