I want to create a Map of objects using multiple lists of different object types. I want to take an example so that it'd be more clear and easy to discuss.
class Employee {
Long id;
String name;
// getters, setters, and toString
}
class Department {
Long id;
String name;
// getters, setters, and toString
}
class EmployeeDepartment {
Long id;
Long employeeId;
Long deptId;
// getters, setters, and toString
}
class Subject {
Long id;
String name;
// getters, setters, and toString
}
class EmployeeSubject {
Long id;
Long employeeId;
Long subjectId;
// getters, setters, and toString
}
Now, I have
List<Employee> emplList;
List<EmployeeDepartment> emplDeptList;
List<EmployeeSubject> emplSubList;
I want to get a Map by which I can make a search of employee using : deptId, and subjectId
Something like
Map<List<Long, Long>, List<Employee>> deptSubToEmpMap;
// representing Map<List<deptId, subId>, List<empl>>
// Or
Map<Long, Map<Long, List<Employee>> deptToSubToEmpMap;
// representing Map<deptId, Map<subId, List<empl>>
or any other convenient form if it's better than above representation.
Note: I'm a newbie to Java Streams
Map<LookupRequest, List<Employee>>as well. Few of your classes are unrelated as they stand for now.Map<List<Long, Long>, List<EmployeeDepartment>>andMap<List<Long, Long>, List<EmployeeSubject>>seperately