-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentQuery.java
More file actions
61 lines (47 loc) · 2.85 KB
/
StudentQuery.java
File metadata and controls
61 lines (47 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package info.kgeorgiy.java.advanced.student;
import java.util.*;
import java.util.stream.Collectors;
/**
* Hard-version interface
* for <a href="https://www.kgeorgiy.info/courses/java-advanced/homeworks.html#homework-student">Student</a> homework
* of <a href="https://www.kgeorgiy.info/courses/java-advanced/">Java Advanced</a> course.
*
* @author Georgiy Korneev (kgeorgiy@kgeorgiy.info)
*/
public interface StudentQuery {
/** Returns student {@link Student#getFirstName() first names}. */
List<String> getFirstNames(final List<Student> students);
/** Returns student {@link Student#getLastName() last names}. */
List<String> getLastNames(final List<Student> students);
/** Returns student {@link Student#getGroup() groups}. */
List<String> getGroups(final List<Student> students);
/** Returns full student name. */
List<String> getFullNames(final List<Student> students);
/** Returns distinct student {@link Student#getFirstName() first names} in alphabetical order. */
Set<String> getDistinctFirstNames(final List<Student> students);
/** Returns name of the student with minimal {@link Student#getId() id}. */
String getMinStudentFirstName(final List<Student> students);
/** Returns list of students sorted by {@link Student#getId() id}. */
List<Student> sortStudentsById(Collection<Student> students);
/**
* Returns list of students sorted by name
* (students are ordered by {@link Student#getLastName() lastName},
* students with equal last names are ordered by {@link Student#getFirstName() firstName},
* students having equal both last and first names are ordered by {@link Student#getId() id}.
*/
List<Student> sortStudentsByName(Collection<Student> students);
/** Returns list of students having specified first name. Students are ordered by name. */
List<Student> findStudentsByFirstName(Collection<Student> students, String name);
/** Returns list of students having specified last name. Students are ordered by name. */
List<Student> findStudentsByLastName(Collection<Student> students, String name);
/** Returns list of students having specified groups. Students are ordered by name. */
List<Student> findStudentsByGroup(Collection<Student> students, String group);
/** Returns map of group's student last names mapped to minimal first name. */
Map<String, String> findStudentNamesByGroup(final Collection<Student> students, final String group);
/** Stable version of {@link #findStudentNamesByGroup(Collection, String)} */
default List<Map.Entry<String, String>> findStudentNamesByGroupList(final List<Student> students, final String group) {
return findStudentNamesByGroup(students, group).entrySet().stream()
.sorted(Comparator.comparing(Map.Entry::getKey))
.collect(Collectors.toUnmodifiableList());
}
}