I have two enum classes College.java and Student.java
here is the code snippet for both the classes.
public enum College {
ID("Id of College"), NAME("Name of College"), ADDRESS("Address of College");
private final String description;
private College(String details) {
this.description = description;
}
}
public enum Student {
ROLL(College.ID, "Roll No of Student"), CLASS(College.NAME, "Class of Student"),
PLACE(College.ADDRESS, "Place of Student"), STUDENTID(setMap());
private final String description;
private final College college;
private Map<college, String> attributes;
private Student(College college, String details) {
this.college = college;
this.details = details;
}
private Student(Map<College, String> attributes) {
this.attributes = attributes;
for(college key: attributes.keySet()) {
this.college=key;
this.description=attributes.get(key);
}
}
private Map<College, String> setMap() {
Map<college, String> map = new HashMap<college, String>();
map.put(College.ID ,"ID of college");
map.put(College.NAME,"Name of Student");
map.put(College.ADDRESS,"Address of the College");
return map;
}
}
My question is that i am unable to set multiple College enum's to one Student enum(STUDENTID). When i tried using a helper method and setting values in Map, It is only setting one value when STUDENTID enum is initialized. I want all the Map values to be initialized for the STUDENTID enum. Is there any other way to do that? Please help me here, I am really stuck here