Moving com.baeldung.modelmmaper package to java-collections-conversations module

This commit is contained in:
Sasa M
2020-04-21 18:46:45 +02:00
parent 0a42d945f8
commit 43852c4303
10 changed files with 140 additions and 88 deletions
@@ -1,36 +0,0 @@
package com.baeldung.util;
import com.baeldung.model.User;
import com.baeldung.model.UserDTO;
import com.baeldung.model.UserList;
import org.modelmapper.AbstractConverter;
import org.modelmapper.Converter;
import org.modelmapper.PropertyMap;
import java.util.ArrayList;
import java.util.List;
/**
* @author sasam0320
* @date 4/18/2020
*/
public class UserPropertyMap extends PropertyMap<UserList, UserDTO> {
Converter<List<User>, List<String>> converter = new AbstractConverter<List<User>, List<String>>() {
List<String> usernames = new ArrayList<>();
protected List<String> convert(List<User> users) {
users.forEach(user -> usernames.add(user.getUserName()));
return usernames;
}
};
@Override
protected void configure() {
using(converter).map(source.getUsers(), destination.getUsernames());
}
}