mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
25 lines
732 B
HTML
25 lines
732 B
HTML
<html>
|
|
<body>
|
|
Reports <code>Optional</code> call chains that can be replaced with a sequence of <code>if</code> statements.
|
|
<p>Example:</p>
|
|
<pre><code>
|
|
return Optional.ofNullable(name)
|
|
.map(this::extractInitials)
|
|
.map(initials -> initials.toUpperCase(Locale.ENGLISH))
|
|
.orElseGet(this::getDefault);
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
if (name != null) {
|
|
String initials = extractInitials(name);
|
|
if (initials != null) return initials.toUpperCase(Locale.ENGLISH);
|
|
}
|
|
return getDefault();
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<p>
|
|
This inspection can help to downgrade for backward compatibility with earlier Java versions.
|
|
</p>
|
|
<p><small>New in 2020.2</small></p>
|
|
</body>
|
|
</html> |