Java to Kotlin auto converter: How to automatically convert Streams to Kotlin functions?

Viewed 133

Using IntelliJ IDEA, I can automatically convert some Java code to Kotlin code. However, when Java code uses things like Stream, it only converts to Kotlin grammar, but it still uses Stream. But we know Kotlin's sequences/collections API is much, much simpler than Java's Stream API, so I would appreciate it if I could automatically convert Stream to Kotlin's API.

For example,

myList.stream().map(x -> x + 1).collect(Collectors.toList()); // java

How to auto convert to:

myList.map { it + 1 } // kotlin

(notice the .map here works on the Iterable, and there is no stream() and collect() anymore).

1 Answers
Related