删除list中元素
实例:
private static void filterAppId(List<API_ORG_SUB_APP_INFO> orgSubAppDetailInfoList,String productId){
if(StringUtil.isNullOrEmpty(orgSubAppDetailInfoList)){
return;
}
for (int i = 0; i < orgSubAppDetailInfoList.size(); i++) {
API_ORG_SUB_APP_INFO productLicenseBean = orgSubAppDetailInfoList.get(i);
if(!productLicenseBean.appId.equals(WorkbenchV2Service.getAppid(productId))){
orgSubAppDetailInfoList.remove(i);
i--;
}
}
}
/***
* 从List中删除指定的对象
*
* @param list
* @param property
* @param valueCompare
*/
public static void deleteOneFromList(List<?> list, String property,
Object valueCompare) {
if (StringUtil.isNullOrEmpty(list)) {
return;
}
List filterList = getObjFromList(list, property, valueCompare);
if (!StringUtil.isNullOrEmpty(filterList)) {
for (Object obj : filterList) {
list.remove(obj);
}
}
}
/***
* 删除成员变量<code>propertyColumn<code>值为null的对象
*
* @param list
* @param propertyColumn
* : 判断其值是否为null
* @throws IllegalAccessException
* @throws IllegalArgumentException
* @throws NoSuchFieldException
* @throws SecurityException
*/
public static void deleteNullEle4List(List<?> list, String propertyColumn)
throws SecurityException, NoSuchFieldException,
IllegalArgumentException, IllegalAccessException {
int length = list.size();
for (int i = 0; i < length; i++) {
Object obj = list.get(i);
Object val = getObjectValue(obj, propertyColumn);
if (val == null) {
list.remove(obj);
length = length - 1;
i = i - 1;
}
}
}