<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections</artifactId>
<version>10.3.0</version>
</dependency>
public class Student {
private String name;
private int age;
private double score;
// getters and setters
@Override
public boolean equals(Object o) {
if (this == o) return true;
Student student = (Student) o;
return age == student.age &&
Double.compare(student.score, score) == 0 &&
Objects.equals(name, student.name);
}
@Override
public int hashCode() {
return Objects.hash(name, age, score);
}
}
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.impl.factory.Lists;
public class StudentManagementSystem {
private MutableList<Student> students = Lists.mutable.empty();
public void addStudent(Student student) {
students.add(student);
}
public MutableList<Student> findStudentsByName(String name) {
return students.select(student -> student.getName().equals(name));
}
public MutableList<Student> findStudentsByAge(int age) {
return students.select(student -> student.getAge() == age);
}
public MutableList<Student> findStudentsByScore(double score) {
return students.select(student -> student.getScore() == score);
}
}