IDEA-205309 'Replace with findFirst()' produces uncompilable source

This commit is contained in:
Tagir Valeev
2019-01-15 12:32:12 +07:00
parent 554aea463a
commit a3ed07435e
3 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
// "Replace with findFirst()" "true"
import java.util.List;
class Scratch {
public void setStatus(List<MutablePair> destinations, String destination, Integer status) {
destinations.stream().filter(pair -> pair.first.compareTo(destination) == 0).findFirst().ifPresent(pair -> pair.second = status);
}
private static class MutablePair {
String first;
Integer second;
}
}

View File

@@ -0,0 +1,19 @@
// "Replace with findFirst()" "true"
import java.util.List;
class Scratch {
public void setStatus(List<MutablePair> destinations, String destination, Integer status) {
fo<caret>r (MutablePair pair : destinations) {
if (pair.first.compareTo(destination) == 0) {
pair.second = status;
return;
}
}
}
private static class MutablePair {
String first;
Integer second;
}
}