backend/restservice/src/main/java/com/plannaplan/responses/models/CoursesWithGroupsResponse.java
2020-12-29 15:32:09 +01:00

45 lines
1.4 KiB
Java
Executable File

package com.plannaplan.responses.models;
import java.util.ArrayList;
import java.util.List;
import com.plannaplan.entities.Course;
import com.plannaplan.responses.models.abstracts.CoursesResponse;
import com.plannaplan.types.GroupType;
import io.swagger.annotations.ApiModel;
@ApiModel(description = "Response shows information about groups to given course.", value = "CoursesWithGroupsResponse")
public class CoursesWithGroupsResponse extends CoursesResponse {
private List<GroupWithCapacityResponse> lectures = new ArrayList<>();
private List<GroupWithCapacityResponse> classes = new ArrayList<>();
public CoursesWithGroupsResponse(Course course) {
super(course);
course.getGroups().stream().forEach(group -> {
if (group.getType() == GroupType.CLASS) {
this.classes.add(new GroupWithCapacityResponse(group));
} else {
this.lectures.add(new GroupWithCapacityResponse(group));
}
});
}
public CoursesWithGroupsResponse(Course course, List<GroupWithCapacityResponse> lectures,
List<GroupWithCapacityResponse> classes) {
super(course);
this.lectures = lectures;
this.classes = classes;
}
public List<GroupWithCapacityResponse> getClasses() {
return this.classes;
}
public List<GroupWithCapacityResponse> getLectures() {
return this.lectures;
}
}