package com.plannaplan.responses.models; import java.util.HashMap; import com.plannaplan.entities.Course; import com.plannaplan.entities.Groups; import com.plannaplan.types.GroupType; import io.swagger.annotations.ApiModel; @ApiModel(description = "Response shows information about given assigment to course.", value = "AssignmentResponse") public class AssignmentResponse { private Long id; private String name; private GroupWithCapacityResponse classes; private GroupWithCapacityResponse lecture; public AssignmentResponse(Course course, Groups lecture, Groups classes) { this.id = course.getId(); this.name = course.getName(); this.lecture = lecture == null ? null : new GroupWithCapacityResponse(lecture); this.classes = classes == null ? null : new GroupWithCapacityResponse(classes); } public AssignmentResponse(Course course, Groups lecture, Groups classes, HashMap ammounts) { this.id = course.getId(); this.name = course.getName(); this.lecture = lecture == null ? null : new GroupWithCapacityResponse(lecture, ammounts.get(lecture.getId())); this.classes = classes == null ? null : new GroupWithCapacityResponse(classes, ammounts.get(classes.getId())); } public AssignmentResponse(Course course, Groups group) { this(course, group.getType() == GroupType.LECTURE ? group : null, group.getType() == GroupType.CLASS ? group : null); } public AssignmentResponse(Course course, Groups group, HashMap ammounts) { this(course, group.getType() == GroupType.LECTURE ? group : null, group.getType() == GroupType.CLASS ? group : null, ammounts); } public GroupWithCapacityResponse getLecture() { return this.lecture; } public GroupWithCapacityResponse getClasses() { return this.classes; } public String getName() { return this.name; } public Long getId() { return this.id; } }