Scala interop with Java overriding method with Object -


i have java interface

public interface ifoo {      list<map<string, object>> getmaps() throws exception; } 

how can override method ? tried :

import scala.collection.javaconverters._ class foo extends ifoo{  override def getmaps: util.list[util.map[string,anyref]]  = {     list(map("a" -> "b")).asjava   } } 

but getting 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 :

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 correct way ?

you need convert map java map well, , there better way provide value type:

list(map[string, anyref]("a" -> "b").asjava).asjava 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -