mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
17 lines
768 B
HTML
17 lines
768 B
HTML
<html>
|
|
<body>
|
|
Reports uses of <code>Optional.ofNullable()</code> where always null or always not-null argument is passed.
|
|
There's no point in using <code>Optional.ofNullable()</code> in this case: either <code>Optional.empty()</code>
|
|
or <code>Optional.of()</code> should be used to explicitly state the intent of creating an always-empty
|
|
or always non-empty optional respectively. It's also possible that there's a mistake in
|
|
<code>Optional.ofNullable()</code> argument, so it should be examined.
|
|
<p>
|
|
Example:
|
|
</p>
|
|
<pre><code>
|
|
Optional<String> empty = Optional.ofNullable(null); // should be Optional.empty();
|
|
Optional<String> present = Optional.ofNullable("value"); // should be Optional.of("value");
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
</body>
|
|
</html> |