Summary: | [1.8][quick assist] Provide quick assist to migrate code to use the new Stream APIs | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Martin Mathew <manju656> |
Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
Status: | ASSIGNED --- | QA Contact: | |
Severity: | enhancement | ||
Priority: | P3 | CC: | jerome.cambon, raffi.khatchadourian, vwu725 |
Version: | 4.4 | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: |
Description
Martin Mathew
2014-04-04 02:15:02 EDT
*** Bug 433028 has been marked as a duplicate of this bug. *** *** Bug 461455 has been marked as a duplicate of this bug. *** (In reply to Manju Mathew from comment #0) > There are a number of new Stream APIs like the #filter, #collect, #forEach, > #count, #mapToInt, #mapToDouble etc. We need to analyze the existing code > and propose appropriate quick assist. > > Like for e.g: > private static void streamA(Collection<String> words) { > int sum = 0; > for (String word : words) { > if (word.startsWith("A")) { > sum++; > } > } > System.out.println(sum); > } > Can be converted as: > private static void streamA(Collection<String> words) { > int sum = (int) words.stream().filter(w -> w.startsWith("A")).count(); > System.out.println(sum); > > } Interesting. When I did this conversion automatically in NetBeans 8.0.2, I got this: int sum = words.stream().filter((word) -> (word.startsWith("A"))).map((_item) -> 1).reduce(sum, Integer::sum); |