I want to loop through enum values continuously. I can solve it outside the enum but I curious is there a way to solve it inside. Error occurs as NOON and EVENING not initialized yet.
@Getter
public enum TimeSlotEnum {
MORNING(NOON, LocalTime.of(9, 0), LocalTime.of(12, 0)),//compile error
NOON(EVENING, LocalTime.of(12, 0), LocalTime.of(15, 0)),//compile error
EVENING(MORNING, LocalTime.of(15, 0), LocalTime.of(18, 30));
private final TimeSlotEnum next;
private final LocalTime start;
private final LocalTime end;
TimeSlotEnum(TimeSlotEnum next, LocalTime start, LocalTime end) {
this.next = next;
this.start = start;
this.end = end;
}
}