mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
21 lines
945 B
HTML
21 lines
945 B
HTML
<html>
|
|
<body>
|
|
Reports null-check conditions and suggests replacing them with <code>Optional</code> chains.
|
|
<p>Example:</p>
|
|
<pre><code>
|
|
return str == null ? "" : str.trim();
|
|
</code></pre>
|
|
<p>After applying the quick-fix:</p>
|
|
<pre><code>
|
|
return Optional.ofNullable(str).map(String::trim).orElse("");
|
|
</code></pre>
|
|
<p>While the replacement is not always shorter, it could be helpful for further refactoring
|
|
(for example, for changing the method return value to <code>Optional</code>).</p>
|
|
<p>Note that when a not-null branch of the condition returns null, the corresponding mapping step will
|
|
produce an empty <code>Optional</code> possibly changing the semantics. If it cannot be statically
|
|
proven that semantics will be preserved, the quick-fix action name will contain the "(may change semantics)"
|
|
notice, and the inspection highlighting will be turned off.</p>
|
|
<!-- tooltip end -->
|
|
<p><small>New in 2018.1</small></p>
|
|
</body>
|
|
</html> |