just wondering if anyone can help me out with something.
Basically I have two objects from different places for example two different car classes. I want to map the properties of class carA to the properties of class carB using a mapper I have created. This is simple enough in most scenarios as can be seen below.
public carB carMapper(carA car){
carB carb = new carB();
carb.weight = car.weight
carb.size = car.size
}
However, there are some scenarios where class CarA stores the corresponding values in a slightly different format to that of CarB, ie, for a model of car which is a Ford carA stores this as Frd but carB stores it as Ford. Is there an easy way (perhaps using enums or something) that I can map these correctly? I know I could do
if (carA.model = frd)
then carB.model = Ford
etc but I dont want to do this for every scenario.... I know the possible values of both carA and carB, could I use an enum in some way to help me out here?
Thanks.
modelvariable inCarAandCarBnow? Are they alreadyenumtype orString? If they are alreadyenumtype, why not use the same enum for bothCarAorCarB?