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

19 lines
549 B
HTML

<html>
<body>
Reports <code>java.util.Optional</code> or <code>com.google.common.base.Optional</code> types with an array or collection type parameter.
<p>In such cases, it is more clear to just use an empty array or collection to indicate the absence of result.</p>
<p><b>Example:</b></p>
<pre><code>
Optional&lt;List&lt;Integer&gt;&gt; foo() {
return Optional.empty();
}
</code></pre>
<p>This code could look like:</p>
<pre><code>
List&lt;Integer&gt; foo() {
return List.of();
}
</code></pre>
<!-- tooltip end -->
</body>
</html>