mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
31 lines
974 B
HTML
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> |