List of usage examples for org.apache.commons.collections CollectionUtils forAllDo
public static void forAllDo(Collection collection, Closure closure)
From source file:org.opencastproject.metadata.dublincore.DublinCoreCatalogImpl.java
@SuppressWarnings("unchecked") public List<String> get(EName property, final String language) { if (property == null) throw new IllegalArgumentException("Property name must not be null"); if (language == null) throw new IllegalArgumentException("Language code must not be null"); if (LANGUAGE_ANY.equals(language)) { return (List<String>) CollectionUtils.collect(getValuesAsList(property), new Transformer() { public Object transform(Object o) { return ((CatalogEntry) o).getValue(); }/*from w w w . jav a 2s .co m*/ }); } else { final List<String> values = new ArrayList<String>(); final boolean langUndef = LANGUAGE_UNDEFINED.equals(language); CollectionUtils.forAllDo(getValuesAsList(property), new Closure() { public void execute(Object o) { CatalogEntry c = (CatalogEntry) o; String lang = c.getAttribute(XML_LANG_ATTR); if ((langUndef && lang == null) || (language.equals(lang))) values.add(c.getValue()); } }); return values; } }
From source file:org.openconcerto.sql.view.listview.ItemPool.java
protected final void forAllDo(final Collection c, final Closure cl) { CollectionUtils.forAllDo(c, cl); }
From source file:org.openconcerto.sql.view.listview.ListSQLView.java
private final void forAllDo(final Cl c) { CollectionUtils.forAllDo(this.items, c); }
From source file:org.openmrs.web.dwr.DWRProviderServiceTest.java
/** * @see DWRProviderService#findProvider(String,boolean,Integer,Integer) * @verifies return the list of providers matching the search name *//*from w w w . ja va 2 s.c o m*/ @Test public void findProvider_shouldReturnTheListOfProvidersMatchingTheSearchName() throws Exception { Vector<Object> providers = service.findProvider("provider", false, 0, 10); Assert.assertEquals(2, providers.size()); final ArrayList<String> providerNames = new ArrayList<String>(); CollectionUtils.forAllDo(providers, new Closure() { @Override public void execute(Object input) { providerNames.add(((ProviderListItem) input).getDisplayName()); } }); Assert.assertTrue(providerNames.containsAll(Arrays.asList("Bruno Otterbourg", "Hippocrates of Cos"))); }
From source file:org.sipfoundry.sipxconfig.admin.commserver.RegistrationMetrics.java
/** * All registrations from registration.xml which may include redunant * registrations from clients that reregister w/slighlty different uri * w/o unregistering last uri.//from w ww .j ava 2s. com */ public void setRegistrations(List registrations) { UniqueRegistrations unique = new UniqueRegistrations(); CollectionUtils.forAllDo(registrations, unique); setUniqueRegistrations(unique.getRegistrations()); }
From source file:org.sipfoundry.sipxconfig.admin.commserver.RegistrationMetrics.java
public double getLoadBalance() { LoadDistribution metric = new LoadDistribution(); // decided to count expired registrations, shouldn't matter and more history // gives a more accurate value. CollectionUtils.forAllDo(m_uniqueRegistrations, metric); double loadBalance = metric.getLoadBalance(); return loadBalance; }
From source file:org.sipfoundry.sipxconfig.site.conference.ActiveConferenceControl.java
private void forAllMembers(Closure closure) { Collection<Integer> selectedUsers = getSelections().getAllSelected(); if (selectedUsers.isEmpty()) { return;//from w w w . ja v a 2 s. c om } CollectionUtils.forAllDo(selectedUsers, closure); // probably some status changes - force new read setMembersCached(null); }
From source file:org.sipfoundry.sipxconfig.site.conference.ConferencesPanel.java
private void forAllConferences(Closure closure) { Collection<Integer> selected = getSelections().getAllSelected(); if (selected.isEmpty()) { return;/*from w ww . ja v a2 s . c o m*/ } CollectionUtils.forAllDo(selected, closure); }
From source file:org.squashtest.tm.domain.library.structures.LibraryTree.java
/** * * <p>Accepts a {@link Closure} that will be applied on the nodes using bottom-up exploration. The method will walk up the tree : * <ul>// w w w.ja va 2s .c om * <li>layer <i>n+1</i> will be treated before layer <i>n</i> (reverse order)</li> * <li>nodes within a given layer will be treated regardless their ordering</li> * </ul> * </p> * @param closure code to apply on the nodes. */ public void doBottomUp(Closure closure) { if (!layers.isEmpty()) { Integer layerIndex = Collections.max(layers.keySet()); while (layerIndex >= 0) { List<T> layer = new ArrayList<>(layers.get(layerIndex)); CollectionUtils.forAllDo(layer, closure); layerIndex--; } } }
From source file:org.squashtest.tm.domain.library.structures.LibraryTree.java
/** * <p>/*from w w w . ja va 2s . c o m*/ * Accepts a {@link Closure} that will be applied on the nodes using top-down exploration. The method will walk down the tree : * <ul> * <li>the layer <i>n</i> will be treated before layer <i>n+1</i> (natural order)</li> * <li>nodes within a given layer will be treated regardless their ordering</li> * </ul> * </p> * @param closure code to apply on the nodes. */ public void doTopDown(Closure closure) { Integer layerIndex = 0; while (layerIndex <= Collections.max(layers.keySet())) { List<T> layer = layers.get(layerIndex); CollectionUtils.forAllDo(layer, closure); layerIndex++; } }