Group capacity response places overload

This commit is contained in:
BuildTools
2020-11-30 12:35:35 +01:00
parent 593084aeba
commit 25e9571a06
3 changed files with 50 additions and 2 deletions

View File

@ -31,9 +31,25 @@ public class GroupsMappers {
return GroupsMappers.mapToDefaultResponse(groups, null);
}
public static List<GroupWithCapacityResponse> mapToCapacityResponse(List<Groups> groups,
HashMap<Long, Integer> taken) {
// return
// groups.stream().filter(Objects::nonNull).map(GroupWithCapacityResponse::new)
// .collect(Collectors.toList());
return groups.stream().filter(Objects::nonNull).map(new Function<Groups, GroupWithCapacityResponse>() {
@Override
public GroupWithCapacityResponse apply(Groups p) {
if (taken != null) {
return new GroupWithCapacityResponse(p, taken.get(p.getId()));
} else {
return new GroupWithCapacityResponse(p);
}
}
}).collect(Collectors.toList());
}
public static List<GroupWithCapacityResponse> mapToCapacityResponse(List<Groups> groups) {
return groups.stream().filter(Objects::nonNull).map(GroupWithCapacityResponse::new)
.collect(Collectors.toList());
return GroupsMappers.mapToCapacityResponse(groups, null);
}
public static CourseWithGroupsResponse<GroupDefaultResponse> mapToGetCourseGroupsDefaultResponse(

View File

@ -23,6 +23,10 @@ public class GroupWithCapacityResponse extends GroupDefaultResponse {
this(assignment.getGroup());
}
public GroupWithCapacityResponse(Assignment assignment, int takenPlaces) {
this(assignment.getGroup(), takenPlaces);
}
public int getCapacity() {
return capacity;
}