私はこのデータ構造を持っています
Class Project {
String status;
Property property ;
String clientName ;
Localdate date;
}
このオブジェクトから、Java 8ストリームメソッドを使用してこのデータ構造を出力として取得したい
{
"Spring hill recent": { //client name
"Dallas": [{ //property name
month: 'January', // date
"overdue": 20, //accumulation based on how much project falls under this status
"inprogress": 30,
"new": 50
}, {
month: 'February',
"overdue": 30,
"inprogress": 40,
"new": 50
}, {
month: 'March',
"overdue": 67,
"inprogress": 45,
"new": 23
}]
month: 'April',
"overdue": 80,
"inprogress": 40,
"new": 20
}, {
month: 'December',
"overdue": 10,
"inprogress": 30,
"new": 30
}, {
month: 'February',
"overdue": 90,
"inprogress": 23,
"new": 56
}],
},
}
これまでのところ、このコードを追加しましたが、累積の方法がわかりません
List<Project> projects = projectRepository.fetchActiveNewAndOverDueProject();
Map<String, Map<String, List<Project>>> collect = projects.stream()
.collect(Collectors.groupingBy(Project::getClientName,
Collectors.groupingBy(property -> property.getProperty(),getName())
))