How to perform a `Collectors.toList()` correspondingly in scala

5.1k Views Asked by At

I have the following class and method used in the code below with ids being a Set[String]:

case class PAV ()

def aggregate(pId: String, iId: Option[String], count: Int): PAV

I have tried the following:

One, using java.util.stream.Collectors

tuple._2.get.ids.toStream
  .map(i => aggregate("some", Option(i), tuple._1.data.`type`))
  .collect(Collectors.toList[PAV]) // required PartialFunction found Function0

Two, using identity

tuple._2.get.ids.toStream
  .map(i => aggregate("some", Option(i), tuple._1.data.`type`))
  .collect(identity(PAV)) // required PartialFunction found PAV.type

I have tried the above based on How do I use java 8's stream collect from scala 2.11?

Curious to know, why not provide a Function to collect?

0

There are 0 best solutions below