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

23 lines
1.0 KiB
HTML

<html>
<body>
Detects transformations outside a Stream API chain that could be incorporated into it.
<p>Example:</p>
<pre><code>
List&lt;String&gt; list = stream.collect(Collectors.toList());
list.sort(null);
return list.toArray(new String[list.size()]);
</code></pre>
<p>After the conversion:</p>
<pre><code>
return stream.sorted().toArray(String[]::new);
</code></pre>
<p>
Note that sometimes the converted stream chain may replace explicit <code>ArrayList</code> with <code>Collectors.toList()</code> or explicit
<code>HashSet</code> with <code>Collectors.toSet()</code>. The current library implementation uses these collections internally. However,
this approach is not very reliable and might change in the future altering the semantics of your code.</p>
<!-- tooltip end -->
<p>If you are concerned about it, use the <b>Do not suggest 'toList()' or 'toSet()' collectors</b> option to suggest
<code>Collectors.toCollection()</code> instead of <code>toList</code> and <code>toSet</code> collectors.
</body>
</html>