Skip to content
Snippets Groups Projects
Commit 03d753e8 authored by Ada Turgut's avatar Ada Turgut
Browse files

Add better return types

parent 4f15aba7
Branches
Tags
2 merge requests!229Version 2.2.1,!203Resolve "Add verification to not put person in two groups at once"
......@@ -277,15 +277,14 @@ public class StudentGroupService {
*
* @param personId the id of the person
* @param moduleId the id of the module
* @return false if there are no other groups the people are in
*/
private Boolean checkIfPersonIsAlreadyInAGroup(Long personId, Long moduleId, String message)
private void checkIfPersonIsAlreadyInAGroup(Long personId, Long moduleId, String message)
throws GroupSwitchingException {
Optional<StudentGroupDetailsDTO> currentGroup = getGroupForPersonInModule(personId, moduleId);
// person is not in any other groups in the module
if (currentGroup.isEmpty()) {
return false;
return;
}
String personName = personCache.get(personId).orElseThrow().getDisplayName();
......@@ -299,14 +298,13 @@ public class StudentGroupService {
*
* @param usernames list of usernames to be checked
* @param moduleId the id of the module
* @return whether if there is a person that is already in a group in the same module
*
*/
private Boolean arePeopleAlreadyInAGroup(Long moduleId, List<String> usernames, String message) {
return usernames
.stream()
.map(name -> personCache.get(name).getId())
.map(id -> checkIfPersonIsAlreadyInAGroup(id, moduleId, message))
.reduce(false, (x, y) -> x || y);
private void arePeopleAlreadyInAGroup(Long moduleId, List<String> usernames, String message) {
for (String name : usernames) {
Long id = personCache.get(name).getId();
checkIfPersonIsAlreadyInAGroup(id, moduleId, message);
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment