Files
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

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&lt;String&gt; empty = Optional.ofNullable(null); // should be Optional.empty();
Optional&lt;String&gt; present = Optional.ofNullable("value"); // should be Optional.of("value");
</code></pre>
<!-- tooltip end -->
</body>
</html>