//整体属性的对比

public static List removeDuplicate(List list){

HashSet hs = new HashSet(list);

list.clear();

list.addAll(hs);

return list;

}

//单个属性的对比

public static List removeDuplicateByString(List list) {

for (int i = 0; i < list.size() - 1; i++) {

for (int j = list.size() - 1; j > i; j--) {

Map mapi = (Map) list.get(i);

Map mapj = (Map) list.get(j);

if (mapi.get("user_name").equals(mapj.get("user_name"))) {

list.remove(j);

}

}

}

return list;

}

//如果List存在,不添加

public static boolean removeSameCompanyName(List list, String companyName) {

for (int i = 0; i < list.size() ; i++) {

Map mapi = (Map) list.get(i);

if (mapi.get("COMPANY_NAME").equals(companyName)) {

return false;

}

}

return true;

}

 

if(removeSameCompanyName(resultList, agentData.get("COMPANY_NAME")+"")){

resultList.add(i, agentData);

}

if(resultList.size() > 9 ){

return resultList;

}