简体   繁体   中英

Using dozer for copying java objects

I am new to dozer framework. I want to copy some objects to a Map using dozer.

For instance Belwo is the example scenario which reflects my requirement.

  public void createUser(String userId,String password,String firstname)
  {
      Map<String,String> userMap=new HashMap<String,String>();

      userMap.put("LoginId",userId);
      userMap.put("password",password);
      userMap.put("FirstName",firstName);

      createUSerInApp(userMap);
   }.

I want to automatically copy the required properties like userId,password,firstname into userMap using dozer.

Can any one give any suggestions.

Thanks,
Narendra

EDIT 1

I was wrong!!!

Check this out . You can specify the key in your map for the property, should work like a charm. :)

I could be wrong, but I know of no built in functionality to perform the mapping you describe, so I think it will take a Custom Converter . Dozer really has great documentation.

I do highly recomend dozer. It may seem like more work setting it up, and learning it, but you have a hold of it (it won't take long to learn) it's really flexible and easy to maintain.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM