Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/StreamToMapInlining2.java
Tagir Valeev 4dfb7b9999 [java-dfa] toMap collector: Flush Map size on update
GitOrigin-RevId: def13d95f991e7601682c03f5a2029ed332dc757
2020-07-24 10:52:50 +00:00

25 lines
1.1 KiB
Java

import java.util.*;
import java.util.stream.*;
class Test {
// IDEA-246544
public static void main(String[] args) {
List<Float> decimals = new ArrayList<>(Arrays.asList(1.2f, 4.4f, 2.7f, 2.5f));
HashMap<Integer, List<Float>> decimalsGroupedByTheirIntegerParts = decimals.stream().collect(Collectors.toMap(
Float::intValue,
Collections::singletonList,
(subgroup1, subgroup2) -> Stream.concat(subgroup1.stream(), subgroup2.stream()).collect(Collectors.toList()),
() -> new HashMap<>()
));
if (decimalsGroupedByTheirIntegerParts.isEmpty()) {}
decimals.clear();
HashMap<Integer, List<Float>> decimalsGroupedByTheirIntegerParts2 = decimals.stream().collect(Collectors.toMap(
Float::intValue,
Collections::singletonList,
(subgroup1, subgroup2) -> Stream.concat(subgroup1.stream(), subgroup2.stream()).collect(Collectors.toList()),
() -> new HashMap<>()
));
if (<warning descr="Condition 'decimalsGroupedByTheirIntegerParts2.isEmpty()' is always 'true'">decimalsGroupedByTheirIntegerParts2.isEmpty()</warning>) {}
}
}