我收到错误,因为类型不匹配无法在下面的代码中从void转换为list ..请帮我解决一下?
public static List<roleBO> convertBOTODOCreateRolebo(List<roleDO> role)
{
java.lang.reflect.Type targetListType = new TypeToken<List<roleBO>>() {}.getType();
List<roleBO> roleboss =new ModelMapper().map(role, targetListType);
return roleboss;
}
答案 0 :(得分:0)
将功能更改为:
public static List<roleBO> convertBOTODOCreateRolebo(List<roleDO> role)
{
List<roleBO> roleboss = role.stream().
map(i -> mapRole(i)).collect(Collectors.toList());
return roleboss;
}
在同一个类中创建函数:
private static roleBO mapRole(roleDO role) {
roleBO result = new roleBO();
// here set properties of result object from properties of role object
return result;
}