[英]Dozer Map DTO Mapping
I have a little "Object": 我有一个小“对象”:
Map<Integer, Map<WeekDay, Map<String, Data>>> obj
and I want to Map it to: 我想将其映射到:
Map<Integer, Map<WeekDay, Map<String, DataDto>>> returnObj
how can I achive this? 我该如何实现?
The way I wanted to use was this one: 我想使用的方式是这样的:
map(schedule, Map<Integer.class, Map<WeekDay.class, Map<String.class, DataDto.class>>>);
but at the "Map" I am stuck, becuase I can't add a .class behind them and in this state it doesn't work... 但是在“地图”上我被困住了,因为我不能在它们后面添加.class,并且在这种状态下它不起作用...
I would suggest to simplify your Map if possible: 如果可能,我建议您简化地图:
class A {
WeekDay weekDay;
String str;
Data obj;
}
Map<Integer, A> map = ...;
Iterables.transform(map.values(), new Function<Data, DataDto>() {
@Override
public Object apply(String input) {
return ...;
}
});
or you can put it inside your class: 或者您可以将其放在班级中:
class Dictionary {
Map<Integer, Map<WeekDay, Map<String, Data>>> obj;
getDataDto(Integer key, Weekday weekDay, String str) {
final Data data = obj.get(key).get(weekDay).get(str);
return (new Function<Data, DataDto>() {
...
}).apply(data);
}
}
Think about operations you are going to use over your data structure and come up with the proper class. 考虑将要在数据结构上使用的操作,并提出适当的类。 Your nested map doesn't look okay. 您的嵌套地图看起来不好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.