SimplifyStreamApiCallChainsInspection: support primitive anyMatch/noneMatch/allMatch conversions

This commit is contained in:
Tagir Valeev
2016-10-07 15:46:11 +07:00
parent a4ed2eab9b
commit ddb1c0e0f4
21 changed files with 96 additions and 24 deletions
@@ -1,4 +1,4 @@
// "Replace Stream.allMatch(x -> !(...)) with Stream.noneMatch(...)" "true"
// "Replace Stream.allMatch(x -> !(...)) with noneMatch(...)" "true"
import java.util.*;
@@ -1,4 +1,4 @@
// "Replace !Stream.allMatch(x -> !(...)) with Stream.anyMatch(...)" "true"
// "Replace !Stream.allMatch(x -> !(...)) with anyMatch(...)" "true"
import java.util.*;
@@ -0,0 +1,10 @@
// "Replace DoubleStream.allMatch(x -> !(...)) with noneMatch(...)" "true"
import java.util.stream.*;
class Test {
public boolean testAllMatch(double[] data) {
if(DoubleStream.of(data).noneMatch(d -> Double.isNaN(d)))
return true;
}
}
@@ -1,4 +1,4 @@
// "Replace !Stream.anyMatch(...) with Stream.noneMatch(...)" "true"
// "Replace !Stream.anyMatch(...) with noneMatch(...)" "true"
import java.util.*;
@@ -1,4 +1,4 @@
// "Replace !Stream.anyMatch(x -> !(...)) with Stream.allMatch(...)" "true"
// "Replace !Stream.anyMatch(x -> !(...)) with allMatch(...)" "true"
import java.util.*;
@@ -0,0 +1,10 @@
// "Replace !LongStream.anyMatch(...) with noneMatch(...)" "true"
import java.util.stream.*;
class Test {
public boolean testAnyMatch(long[] data) {
if(LongStream.of(data).noneMatch(i -> i > 0))
return true;
}
}
@@ -1,4 +1,4 @@
// "Replace !Stream.noneMatch(...) with Stream.anyMatch(...)" "true"
// "Replace !Stream.noneMatch(...) with anyMatch(...)" "true"
import java.util.*;
@@ -1,4 +1,4 @@
// "Replace Stream.noneMatch(x -> !(...)) with Stream.allMatch(...)" "true"
// "Replace Stream.noneMatch(x -> !(...)) with allMatch(...)" "true"
import java.util.*;
@@ -0,0 +1,10 @@
// "Replace !IntStream.noneMatch(...) with anyMatch(...)" "true"
import java.util.stream.*;
class Test {
public boolean testNoneMatch(int[] data) {
if(IntStream.of(data).anyMatch(i -> i > 0))
return true;
}
}
@@ -1,4 +1,4 @@
// "Replace Stream.allMatch(x -> !(...)) with Stream.noneMatch(...)" "false"
// "Replace Stream.allMatch(x -> !(...)) with noneMatch(...)" "false"
import java.util.*;
@@ -1,4 +1,4 @@
// "Replace Stream.allMatch(x -> !(...)) with Stream.noneMatch(...)" "true"
// "Replace Stream.allMatch(x -> !(...)) with noneMatch(...)" "true"
import java.util.*;
@@ -1,4 +1,4 @@
// "Replace !Stream.allMatch(x -> !(...)) with Stream.anyMatch(...)" "true"
// "Replace !Stream.allMatch(x -> !(...)) with anyMatch(...)" "true"
import java.util.*;
@@ -0,0 +1,10 @@
// "Replace DoubleStream.allMatch(x -> !(...)) with noneMatch(...)" "true"
import java.util.stream.*;
class Test {
public boolean testAllMatch(double[] data) {
if(DoubleStream.of(data).allM<caret>atch(d -> !Double.isNaN(d)))
return true;
}
}
@@ -1,4 +1,4 @@
// "Replace !Stream.anyMatch(...) with Stream.noneMatch(...)" "true"
// "Replace !Stream.anyMatch(...) with noneMatch(...)" "true"
import java.util.*;
@@ -1,4 +1,4 @@
// "Replace !Stream.anyMatch(x -> !(...)) with Stream.allMatch(...)" "false"
// "Replace !Stream.anyMatch(x -> !(...)) with allMatch(...)" "false"
import java.util.*;
@@ -1,4 +1,4 @@
// "Replace !Stream.anyMatch(x -> !(...)) with Stream.allMatch(...)" "true"
// "Replace !Stream.anyMatch(x -> !(...)) with allMatch(...)" "true"
import java.util.*;
@@ -0,0 +1,10 @@
// "Replace !LongStream.anyMatch(...) with noneMatch(...)" "true"
import java.util.stream.*;
class Test {
public boolean testAnyMatch(long[] data) {
if(!LongStream.of(data).anyM<caret>atch(i -> i > 0))
return true;
}
}
@@ -1,4 +1,4 @@
// "Replace !Stream.noneMatch(...) with Stream.anyMatch(...)" "true"
// "Replace !Stream.noneMatch(...) with anyMatch(...)" "true"
import java.util.*;
@@ -1,4 +1,4 @@
// "Replace Stream.noneMatch(x -> !(...)) with Stream.allMatch(...)" "true"
// "Replace Stream.noneMatch(x -> !(...)) with allMatch(...)" "true"
import java.util.*;
@@ -0,0 +1,10 @@
// "Replace !IntStream.noneMatch(...) with anyMatch(...)" "true"
import java.util.stream.*;
class Test {
public boolean testNoneMatch(int[] data) {
if(!IntStream.of(data).noneM<caret>atch(i -> i > 0))
return true;
}
}