package ru.ulstu.timeline.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; import static ru.ulstu.core.util.StreamApiUtils.convert; public class TimelineDto { private final Integer id; private final List events; @JsonCreator public TimelineDto(@JsonProperty("id") Integer id, @JsonProperty("events") List events) { this.id = id; this.events = events; } public TimelineDto(Timeline timeline) { this.id = timeline.getId(); this.events = convert(timeline.getEvents(), EventDto::new); } public Integer getId() { return id; } public List getEvents() { return events; } }