All pastes #167070 Raw Edit

Untitled

public text v1 · immutable
·published 2006-09-11 16:57 UTC
rendered paste body
Before:

for (Iterator it = bean.getPlans().iterator(); it.hasNext() && !networkFound;) {
	plan = (LocatorPlan) it.next();
    if ( plan.getRelatedNetworks() != null) {
		NetworkBean network = null;
		for (Iterator it1 = plan.getRelatedNetworks().getNetworks().iterator(); it1.hasNext() && !networkFound;) {
		    network = (NetworkBean) it1.next();
		    networkFound = (network.getCcsId() == pid);
		}
    }
}


After:


LocatorPlan found = (LocatorPlan)CollectionUtils.find(plans, new Predicate() {
    public boolean evaluate(Object object) {
        NetworkBean found = (NetworkBean)CollectionUtils.find(((LocatorPlan)object).getRelatedNetworks().getNetworks(), new Predicate() {
            public boolean evaluate(Object object) {
                NetworkBean network = (NetworkBean)object;
                return (network.getCcsId() == pid); 
            }
        });
        return found != null;
    }
});