Trying to create a "provider" in scala using generics -
i trying create provider class in scala return correct object when called
trait
trait remotevalidator[a <:widget]{ def processremotevalidation(request: eventrequest[_], widget: a): future[seq[widget]] }
class extending trait
class resourceinstancelistremotevalidator @inject() extends remotevalidator[instancelistwidget[instancewidget]] { override def processremotevalidation(request: eventrequest[_], widget: instancelistwidget[instancewidget]): future[seq[widget]] = { //stuff }
provider
class remotevalidatorprovider[t] @inject()(resourceinstancelistremotevalidator: resourceinstancelistremotevalidator) { val validators = map("resources" -> resourceinstancelistremotevalidator) def getremotevalidator(key: string): option[remotevalidator] = { validators.get(key) } }
the issuse when call provider.processremotevalidation(request, instancelistwidget) "type mismatch expected type a, actual instancelistwidget[instancewidget]. know work in java, not familiar generics in scala, should doing instead?
Comments
Post a Comment