Use the CompilerWarnings
class to suppress compiler warnings like this:
@SuppressWarnings(CompilerWarnings.NLS)
final String myText = "hello world!";
Add de.xn__ho_hia.quality.suppression.CompilerWarnings.*
as a favorite to your IDE, e.g. use Java > Editor > Content Assist > Favorites
in Eclipse. This allows will instruct Eclipse to auto import the constant you specified statically which reduces the code to this:
@SuppressWarnings(NLS)
final String myText = "hello world!";
Take a look at the JavaDoc to see a list of all available constants. All of them contain a (short) description which should help out developers who have not seen those suppressions before. Referencing those constants instead of using plain strings will make sure that all suppressions are correct.
To use this project just declare the following dependency inside your POM:
<dependency>
<groupId>de.xn--ho-hia.quality</groupId>
<artifactId>suppress-warnings</artifactId>
<version>${version.suppress-warnings}</version>
</dependency
Replace ${version.suppress-warnings}
with the latest release. This project follows the semantic versioning guidelines.
To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see http://creativecommons.org/publicdomain/zero/1.0/.