views:

97

answers:

2

Problem: Need to implement interface from 3rd party Java library in Scala

...

Collection<?> getItemPropertyIds()

...

My solution is to use ...<here goes Iterable>.asInstanceOf[java.util.Collection[_]]

 val props:Map[Object,Property] = ...
 override def getItemPropertyIds()=props.keys.asInstanceOf[java.util.Collection[_]]

Is there better solution? Maybe with Predef's implicits?

+1  A: 

Create some scala.Iterable, use scala.collection.asJavaCollection() (may be implicitly) to convert to java.util.Collection.

venechka
+1  A: 

I try also this:

import scala.collection.JavaConversions
...
override def getItemPropertyIds() = JavaConversions.asCollection(props.keys)
sgp
So, did this solution work the way you want (and are you happy with it), or didn't it?
Arjan Blokzijl
This solution works. I'll stay with it.
sgp