Hi all,
I have the following Collection declared as followed. How do i check whether the return collection is null or empty?
say i have: ml = getReport((List)mndDataLst);
I have tried to check whether return data list is null as described but it does not work.
if(ml == null || ml.isEmpty()){
//doesn't execute this block
}
Can anyone kindly advise me?
public static Collection getReport(List dataList) {
if (dataList == null || dataList.isEmpty()) {
return new ArrayList();
}
Collections.sort(dataList, new Comparator() {
public int compare(Object a, Object b) {
if (a != null && b !=null) {
Val[] v1 = ((ReportRow)a).getData();
String c = (String)v1[3].getData();
Val[] v2 = ((ReportRow)b).getData();
String d = (String) v2[3].getData();
return (c.compareTo(d));
}
else if (a== null && b !=null) {
return -1;
}
else
return 1;
}
});
return dataList;
}
I have the following Collection declared as followed. How do i check whether the return collection is null or empty?
say i have: ml = getReport((List)mndDataLst);
I have tried to check whether return data list is null as described but it does not work.
if(ml == null || ml.isEmpty()){
//doesn't execute this block
}
Can anyone kindly advise me?
public static Collection getReport(List dataList) {
if (dataList == null || dataList.isEmpty()) {
return new ArrayList();
}
Collections.sort(dataList, new Comparator() {
public int compare(Object a, Object b) {
if (a != null && b !=null) {
Val[] v1 = ((ReportRow)a).getData();
String c = (String)v1[3].getData();
Val[] v2 = ((ReportRow)b).getData();
String d = (String) v2[3].getData();
return (c.compareTo(d));
}
else if (a== null && b !=null) {
return -1;
}
else
return 1;
}
});
return dataList;
}