I have this Java interface
public interface IFoo {
List<Map<String, Object>> getMaps() throws Exception;
}
how can I override this method ? i tried :
import scala.collection.JavaConverters._
class Foo extends IFoo{
override def getMaps: util.List[util.Map[String,AnyRef]] = {
List(Map("A" -> "B")).asJava
}
}
but I am getting this compilation error
overriding method getMaps in trait IFoo of type ()java.util.List[java.util.Map[String,Object]]; [ERROR] method getMaps has incompatible type
I can do something like :
import scala.collection.JavaConverters._
class Foo extends IFoo{
override def getMaps: util.List[util.Map[String,AnyRef]] = {
List(Map("A" -> "B".asInstanceOf[AnyRef)).asJava
}
}
But is it the correct way ?