I have a wrapper class of picklist values and labels. I am creating a map with picklistValues and List as key and value types. Now, I am getting an error won this line -- objResults.get(controlPicklist).add(depPicklist);
It is saying that i am referencing a null object. When I do show just this line -- >objResults.get(controlPicklist), the value is null, wherein it should return (). Unless I am constructing the key wrong?
Here are what displays on my debug logs.
ObjResults Controllers: objResults controllers : {picklistValues:[label=CustomerService, value=CustomerService]=(), picklistValues:[label=OCM, value=OCM]=(), picklistValues:[label=Facilities Management, value=Facilities Management]=(), picklistValues:[label=Accounts, value=Accounts]=(), picklistValues:[label=Marketing PR, value=Marketing PR]=(), picklistValues:[label=Talent Management, value=Talent Management]=(), picklistValues:[label=Sales, value=Sales]=(), picklistValues:[label=Admin, value=Admin]=()}
controllerValues controllers : {0=CustomerService, 1=OCM, 2=Facilities Management, 3=Accounts, 4=Marketing PR, 5=Talent Management, 6=Sales, 7=Admin}
controlPicklist : picklistValues:[label=CustomerService, value=CustomerService]
public class picklistValues{
@AuraEnabled public String value {get;set;}
@AuraEnabled public String label {get;set;}
}
Map<picklistValues,List<picklistValues>> objResults = new Map<picklistValues,List<picklistValues>>();
for(String controller : pvw.controllerValues.keySet()){
controllerValues.put(pvw.controllerValues.get(controller),controller);
picklistValues picklist = new picklistValues();
picklist.value = controller;
picklist.label = controller;
objResults.put(picklist,new List<picklistValues>());
}
system.debug('objResults controllers : ' + objResults);
system.debug('controllerValues controllers : ' + controllerValues);
for(fieldValues field : pvw.values){
for(String index : field.validFor){
String controllerField = controllerValues.get(Integer.valueOf(index));
system.debug('controllerField : ' + controllerField);
picklistValues controlPicklist = new picklistValues();
controlPicklist.label = controllerField;
controlPicklist.value = controllerField;
system.debug('controlPicklist ' + controlPicklist);
picklistValues depPicklist = new picklistValues();
depPicklist.value = field.value;
depPicklist.label = field.label;
system.debug(objResults.keySet());
system.debug(objResults.containsKey(controlPicklist));
objResults.get(controlPicklist).add(depPicklist);
}
}