paypal - Object translation into another object with the same data? Java -


i using paypal's soap api has concrete class called addresstype.

https://developer.paypal.com/docs/classic/api/merchant/setexpresscheckout_api_operation_soap/

before can pass shipping information paypal need translate current shipping object of type address.

currently doing inside logic not pretty.

    addresstype shippingaddress = new addresstype();     address input = storedorderdetails.getshippingdetails().getshippingaddress();     shippingaddress.setstreet1(input.getaddressline1());     shippingaddress.setpostalcode(input.getpostcode());     shippingaddress.setcityname(input.gettown());     shippingaddress.setcountryname(input.getcountryname()); 

is there better way this, tried casting since classes properties , method signatures don't match won't work.

any suggestions welcome.

you can go bean-mapping frameworks such orika or dozer. both of them , i've done projects each one. there more 20 bean mapping frameworks didn't try them all.

both of them map similar properties of source , destination objects automatically out of box, can map dissimilar properties in static mappings.xml files or dynamically using programming apis.

they can more simple mapping, such converting lists maps or flatten hierarchy of objects simple object , on. don't think need these kind of features in project now.

in general, using or not using these kind of frameworks have pros. , cons. can tell, if these kind of type mappings not frequent in codes, don't make projects complicated using them, , them manually did.

good luck.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -