Intellij-Jetbrains is a very smart development environment and itself offers you a way to solve many problems.
Take a look at the screenshot below. He offers five ways to resolve this warning:
1) add assert value != null ;
2) replace the return statement with return value != null ? value.toString() : null; return value != null ? value.toString() : null;
3) surround with
if (value != null) { return value.toString(); }
4) suppress the check for this particular statement by adding a comment:
//noinspection ConstantConditions return value.toString();
5) add at least as before @ochi suggested using the @SuppressWarnings("ConstantConditions") annotation, which can be used for the method or for the whole class.
To call this context menu, use the keyboard shortcuts Alt+Enter (I think that they are common to all OSs).

source share