@Override
  public boolean checkIfStudentGroupIsEmpty(Attends attend, StudentGroup studentGroup) {

    final Collection allStudentGroupAttends = studentGroup.getAttendsSet();
    if (allStudentGroupAttends.size() == 1 && allStudentGroupAttends.contains(attend)) {
      return true;
    }
    return false;
  }
  @Override
  public boolean checkAlreadyEnroled(Grouping grouping, String studentUsername) {

    final Attends studentAttend = grouping.getStudentAttend(studentUsername);

    if (studentAttend != null) {
      Collection<StudentGroup> groupingStudentGroups = grouping.getStudentGroupsSet();
      for (final StudentGroup studentGroup : groupingStudentGroups) {
        Collection<Attends> studentGroupAttends = studentGroup.getAttendsSet();
        for (final Attends attend : studentGroupAttends) {
          if (attend == studentAttend) {
            return true;
          }
        }
      }
    }
    return false;
  }
  @Override
  public boolean checkPossibleToEnrolInExistingGroup(Grouping grouping, StudentGroup studentGroup) {

    final int numberOfElements = studentGroup.getAttendsSet().size();
    final Integer maximumCapacity = grouping.getMaximumCapacity();
    if (maximumCapacity == null) {
      return true;
    }
    if (numberOfElements < maximumCapacity) {
      return true;
    }

    return false;
  }