Switching from Essentials4J to Kotlin

At work we had a project that used Essentials4J and its predecessor Rapidoid Fluent, to simplify some stream/collection APIs. We were converting this project to Kotlin, and no longer need that library due to features of Kotlin's standard library. The conversion was actually fairly straightforward.


List<Thing> things = new ArrayList<Thing>();
//add some things to it
Map<String, List<Thing>> byName = Do.group(things).by(Thing::getName);
val things = mutableListOf<Thing>()
// add some things to it
val byName = things.groupBy { it.name }


List<Thing> names = Do.map(things).to(Thing::getName)
val names: List<String> = things.map { it.name }

Do.map(...).to(...) with unique values

Map<Integer, Thing> mapped = Do.map(things).to(Thing::getId, p -> p);
val mapped: Map<Int,Thing> = things.associateBy { it.id }


Leave a Reply