Anton Romanov 4f47b1beb6 fix code
2019-03-04 10:28:46 +04:00

68 lines
1.5 KiB
Java

package ru.ulstu.project.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.hibernate.validator.constraints.NotEmpty;
import ru.ulstu.deadline.model.DeadlineDto;
import java.util.ArrayList;
import java.util.List;
import static ru.ulstu.core.util.StreamApiUtils.convert;
public class ProjectDto {
private Integer id;
@NotEmpty
private String title;
private List<DeadlineDto> deadlines = new ArrayList<>();
public ProjectDto() {
}
public ProjectDto(String title) {
this.title = title;
}
@JsonCreator
public ProjectDto(@JsonProperty("id") Integer id,
@JsonProperty("title") String title,
@JsonProperty("deadlines") List<DeadlineDto> deadlines) {
this.id = id;
this.title = title;
this.deadlines = deadlines;
}
public ProjectDto(Project project) {
this.id = project.getId();
this.title = project.getTitle();
this.deadlines = convert(project.getDeadlines(), DeadlineDto::new);
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public List<DeadlineDto> getDeadlines() {
return deadlines;
}
public void setDeadlines(List<DeadlineDto> deadlines) {
this.deadlines = deadlines;
}
}