mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
23 lines
1.0 KiB
HTML
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<String> 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> |