DTO pattern: Best way to copy properties between two objects

后端 未结 6 1304
死守一世寂寞
死守一世寂寞 2020-12-12 12:33

In my application\'s architecture I usually send the object or list of objects from the data access layer to the web layer via the service layer, in which these objects get

6条回答
  •  再見小時候
    2020-12-12 13:10

    Wouldn't lambdaj's project function do what you are looking for?

    It'll look something like this:

    List userNDtos = project(users, UserDTO.class, on(User.class).getUserName(), on(User.class).getFullName(), .....);
    

    (Define the constructor for UserDTO accordingly...)

    Also see here for examples...

提交回复
热议问题