Die Daten sehen so aus:
Code: Select all
2021-06-20
AMBULANCE\CA\Los Angeles
Morning
4
Afternoon
5
Nights
5
AMBULANCE\CA\San Deigo
Afternoon
7
Nights
6
Morning
4
2021-06-21
AMBULANCE\CA\Los Angeles
Night
6
Morning
5
Afternoon
5
ANBULANCE\CA\San Francisco
Afternoon
5
Morning
4
....
Code: Select all
public class RootNode {
public RootNode(){}
public Set shiftDateSet;
}
public class ShiftDate {
public LocalDate date;
public Set location;
}
public class Location {
public Set shifts;
}
public class ShiftType {
public enum ShiftTypes {
MORNING, AFTERNOON, NIGHT
}
public Integer count;
}
Code: Select all
RootNode rootNode = new RootNode();
for (Entities e: rootJsonNode.someEntity) {
LocalDate someDate;
someDate = e.dto.startDateTime.toLocalDate();
if (!rootNode.get(someDate)) {
rootNode.shiftDateSet.add(new ShiftDate(date, new Set ))
// the line above should add a new date AND add
// new Set but do not need to bind to
// a name for the Set.
}
if (rootNode.get(someDate)) {
// node already exists, so add stuff and increment counter
}
}
Letztendlich möchte ich auf rootNode.getShiftDate(date).getLocation(location).getShiftType(type).getCount(); zugreifen können.
Wie mache ich das?
Mobile version