Files
openide/java/java-impl/resources/inspectionDescriptions/ReplaceNullCheck.html
2025-02-05 04:43:28 +00:00

24 lines
758 B
HTML

<html>
<body>
Reports <code>null</code> checks that can be replaced with a call to a static method from <code>Objects</code> or <code>Stream</code>.
<p><b>Example:</b></p>
<pre><code>
if (message == null) {
application.messageStorage().save(new EmptyMessage());
} else {
application.messageStorage().save(message);
}
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
application.messageStorage()
.save(Objects.requireNonNullElseGet(message, () -> new EmptyMessage()));
</code></pre>
<!-- tooltip end -->
<p>
Use the <b>Don't warn if the replacement is longer than the original</b> option to ignore the cases when the replacement is longer than the
original code.
</p>
<p><small>New in 2017.3</small></p>
</body>
</html>