I have a Student object constructed with 3 parameters; id, startdate, enddate. I have created a Map using Student class. I want to extract the students who have the same startDate and endDate s with the given date parameters. As I understand I can access all the 3 parameters with requestparams.values()
but since I want to compare dates separately I need to access each one of them. Is there a method or a way to do this?
Some parts of my code
public class StudentService {
private Map<String,Student> requestparams = DatabaseClass.getStudents();
public StudentService()
{
requestparams.put("123", new Student("123", "2017" , "2018"));
requestparams.put("1234", new Student("1234", "2016" , "2017"));
requestparams.put("8563", new Student("8563", "2015" , "2016"));
}
public List<Student> getFilteredStudent(String id, String startDate, String endDate)
{
List<Student> filteredStudents = new ArrayList<>();
for(String key : requestparams.keySet()){
if(key.equals(id) && /*requestparams.values().startDate == startDate something like this*/ ){
filteredStudents.add(requestparams.get(key));
}
}
return filteredStudents;
}