cfyme 2012-09-06 14:26
浏览 227
已采纳

求高手帮我重构下这段代码

 

private boolean isAllWhiteNameListShop(List<CqShopReportInfoDO> shopReportInfoList) {
        for (int i = 0; i < shopReportInfoList.size(); i++) {
            CqShopReportInfoDO obj = shopReportInfoList.get(i);
            if (!isWhiteNameList(obj.getStatus(), obj.getDealerId(), obj.getDealerNick())) {
                return false; 
            }
        }
        return true;
    }

    private boolean isAllWhiteNameListAuction(List<CqAuctionReportInfoDO> auctionReportInfoList) {
        for (int i = 0; i < auctionReportInfoList.size(); i++) {
            CqAuctionReportInfoDO obj = auctionReportInfoList.get(i);
            if (!isWhiteNameList(obj.getStatus(), obj.getDealerId(), obj.getDealerNick())) {
                return false;
            }
        }
        return true;
    }
想把上面两个方法 重构成一个方法 ,本人水平有限,求高手帮我重构下,谢谢
  • 写回答

6条回答 默认 最新

  • jinnianshilongnian 2012-09-06 14:37
    关注

    格式化一下。。。

    CqAuctionReportInfoDO 和 CqShopReportInfoDO 继承ReportInfoDO(status、dealerId、dealerNick…… 共性属性)

    [code="java"]private boolean isAllWhiteNameListShop(List<? extends ReportInfoDO> reportInfoList) {
    for (ReportInfoDO obj : reportInfoList) {
    if (!isWhiteNameList(obj.getStatus(), obj.getDealerId(), obj.getDealerNick())) {
    return false;
    }
    }
    return true;
    } [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?