mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
IDEA-166896 Simplify stream chain in case of *match used with Boolean::booleanValue
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
// "Merge with previous 'map' call" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
public <T extends Boolean> boolean test(List<String> list, Function<String, T> fn) {
|
||||
return list.stream().allMatch(fn::apply);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Merge with previous 'map' call" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
public <T extends Boolean> boolean test(List<String> list, Function<String, T> fn, Function<String, Boolean> fn2, boolean b, boolean b2) {
|
||||
return list.stream().allMatch((b ? fn : b2 ? fn2 : fn)::apply);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Merge with previous 'map' call" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
public <T extends Boolean> boolean test(List<String> list, Function<String, T> fn, Function<String, Boolean> fn2, boolean b) {
|
||||
return list.stream().allMatch((b ? fn : fn2)::apply);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Merge with previous 'map' call" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
public <T extends Boolean> boolean test(List<String> list, boolean b, boolean b2) {
|
||||
return list.stream().allMatch(b ? String::isEmpty : b2 ? "foo"::equals : "bar"::equals);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Merge with previous 'map' call" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public boolean test(List<String> list) {
|
||||
return list.stream().allMatch(String::isEmpty);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Merge with previous 'map' call" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public boolean test(List<String> list) {
|
||||
/* ditto boolean!*/
|
||||
return list.stream().anyMatch(String::isEmpty);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Merge with previous 'map' call" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public boolean test(List<String> list) {
|
||||
return list.stream().noneMatch(String::isEmpty);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Merge with previous 'map' call" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
public <T extends Boolean> boolean test(List<String> list, Function<String, T> fn) {
|
||||
return list.stream().map(fn).all<caret>Match(Boolean::booleanValue);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Merge with previous 'map' call" "false"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
interface MyFunction extends Function<Object, Boolean> {};
|
||||
|
||||
MyFunction fn3 = "xyz"::equals;
|
||||
|
||||
public <T extends Boolean> boolean test(List<String> list, Function<String, T> fn, Function<String, Boolean> fn2, boolean b, boolean b2) {
|
||||
// neither "b ? fn : b2 ? fn2 : fn3" nor "(b ? fn : b2 ? fn2 : fn3)::apply" can serve as predicate
|
||||
// all possible replacements are longer
|
||||
return list.stream().map(b ? fn : b2 ? fn2 : fn3).all<caret>Match(Boolean::booleanValue);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Merge with previous 'map' call" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
public <T extends Boolean> boolean test(List<String> list, Function<String, T> fn, Function<String, Boolean> fn2, boolean b, boolean b2) {
|
||||
return list.stream().map(b ? fn : b2 ? fn2 : fn).allM<caret>atch(Boolean::booleanValue);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Merge with previous 'map' call" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
public <T extends Boolean> boolean test(List<String> list, Function<String, T> fn, Function<String, Boolean> fn2, boolean b) {
|
||||
return list.stream().map(b ? fn : fn2).all<caret>Match(Boolean::booleanValue);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Merge with previous 'map' call" "false"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
public <T extends Boolean> boolean test(List<String> list, Function<String, T> fn, boolean b) {
|
||||
// neither "b ? String::isEmpty : fn" nor "(b ? String::isEmpty : fn)::apply" can serve as predicate
|
||||
// all possible replacements are longer
|
||||
return list.stream().map(b ? String::isEmpty : fn).all<caret>Match(Boolean::booleanValue);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Merge with previous 'map' call" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Test {
|
||||
public <T extends Boolean> boolean test(List<String> list, boolean b, boolean b2) {
|
||||
return list.stream().map(b ? String::isEmpty : b2 ? "foo"::equals : "bar"::equals).allM<caret>atch(Boolean::booleanValue);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Merge with previous 'map' call" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public boolean test(List<String> list) {
|
||||
return list.stream().map(String::isEmpty).allMa<caret>tch(b -> {
|
||||
return Boolean.valueOf(b);
|
||||
});
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Merge with previous 'map' call" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public boolean test(List<String> list) {
|
||||
return list.stream().map(String::isEmpty).a<caret>nyMatch(/* ditto boolean!*/Boolean::booleanValue);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Merge with previous 'map' call" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public boolean test(List<String> list) {
|
||||
return list.stream().map(String::isEmpty).none<caret>Match(b -> b);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user