删除list中元素

删除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;
            }
        }
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值