I have 5 web services, A, B, C, D, and E. Each of them has auto-generated objects of the same structure, but with different names and in different packages.
com.ws.a.carA contains parameters and com.ws.a.wheelA com.ws.b.carB contains parameters and com.ws.b.wheelB com.ws.c.carC contains parameters and com.ws.c.wheelC com.ws.d.carD contains parameters and com.ws.d.wheelD com.ws.e.carE contains parameters and com.ws.e.wheelE
I want to create one function that can convert each of these objects (and the inner wheel) into an object named
com.model.car,
but I do not have as many functions as:
com.model.car convert(com.ws.a.objA obj) com.model.car convert(com.ws.b.objB obj)
...
The problem is that I cannot give all objects a common interface for implementation, because I do not want to manually change the automatically generated classes (they are often recreated).
I need a way, perhaps with generics, to create a generic function
com.model.car convert(T obj)
which will work for all types of cars, but I'm not sure how to implement it.
source share