I am new to Scala and struggling with the following:
I have database objects (type BaseDoc) and value objects (type BaseVO). Now there are several conversion methods (all called "convert") that take an instance of an object and accordingly convert it to another type: for example:
def convert(doc: ClickDoc): ClickVO = ...
def convert(doc: PointDoc): PointVO = ...
def convert(doc: WindowDoc): WindowVO = ...
Now I sometimes need to convert a list of objects. How would I do this - I tried:
def convert[D <: BaseDoc, V <: BaseVO](docs: List[D]):List[V] = docs match {
case List() => List()
case xs => xs.map(doc => convert(doc))
}
The result is "the overloaded value of the method value with alternatives ...". I tried to add manifest information to it, but could not get it to work.
I could not even create one method for each, because it would say that they have the same type of parameter after deleting the type (List).
Ideas are welcome!