I have made two Lists like
List<LearnerEnrollment> learnerEnrollmentList = new ArrayList<LearnerEnrollment>();
List<LearnerCourseEnrollError> enrollErrorList = new ArrayList<LearnerCourseEnrollError>();
Then i made two Maps like
Map<String, List<LearnerCourseEnrollError>> courseErrorMap = new HashMap<String, List<LearnerCourseEnrollError>>();
Map<String, List<LearnerEnrollment>> courseSuccessMap = new HashMap<String, List<LearnerEnrollment>>();
Then i made another Map to hold the above two Maps like
Map<String, Map<String, List<Object>>> courseMap = new HashMap<String, Map<String, List<Object>>>();
Then i use the following code to add items in lists;
for (com.softech.vu360.lms.model.Course course : courseList) {
Object result = getEnrollmentForCourse(customer, learner, course);
if (result instanceof LearnerEnrollment) {
LearnerEnrollment newEnrollment = (LearnerEnrollment)result;
learnerEnrollmentList.add(newEnrollment);
} else if (result instanceof String) {
String errorMessage = (String)result;
LearnerCourseEnrollError enrollError = new LearnerCourseEnrollError(errorMessage, course);
enrollErrorList.add(enrollError);
}
}
Now i am putting values in the Map
courseSuccessMap.put(learner.getVu360User().getUsername(), learnerEnrollmentList);
courseErrorMap.put(learner.getVu360User().getUsername(), enrollErrorList);
courseMap.put("successfulCoursesMap", courseSuccessMap);
courseMap.put("unSuccessfulCoursesMap", courseErrorMap);
return courseMap;
But i am getting error at these two lines
courseMap.put("successfulCoursesMap", courseSuccessMap);
courseMap.put("unSuccessfulCoursesMap", courseErrorMap);
that
The method put(String, Map<String,List<Object>>) in the type
Map<String,Map<String,List<Object>>> is not applicable for the arguments
(String, Map<String,List<LearnerEnrollment>>)
The method put(String, Map<String,List<Object>>) in the type
Map<String,Map<String,List<Object>>> is not applicable for the arguments
(String, Map<String,List<LearnerCourseEnrollError>>)
Why?
My list type in the Map is List<Object> and List<LearnerEnrollment> is List <Object> because LearnerEnrollment extends Object. Why I am getting these errors ?
If i declare my Map like this
Map<String, Map<String, ?>> courseMap = new HashMap<String, Map<String, ?>>();
Then there is no error. Why i am getting error in first case?
Thanks