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

31 lines
974 B
HTML

<html>
<body>
Reports expressions with a repeating pattern that could be replaced with <i>Stream API</i> or a <code>String.join()</code> call.
<p>Example:</p>
<pre><code>
boolean allStartWith(String a, String b, String c, String d, String prefix) {
return a.startsWith(prefix) && b.startsWith(prefix) && c.startsWith(prefix) && d.startsWith(prefix);
}
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
boolean foo(String a, String b, String c, String d, String prefix) {
return Stream.of(a, b, c, d).allMatch(s -> s.startsWith(prefix));
}
</code></pre>
<p>Example:</p>
<pre><code>
String joinAll(String a, String b, String c, String d) {
return a + "," + b + "," + c + "," + d;
}
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
String joinAll(String a, String b, String c, String d) {
return String.join(",", a, b, c, d);
}
</code></pre>
<!-- tooltip end -->
<p><small>New in 2018.2</small></p>
</body>
</html>