List of usage examples for org.apache.commons.collections CollectionUtils countMatches
public static int countMatches(Collection inputCollection, Predicate predicate)
From source file:org.opencastproject.serviceregistry.impl.jmx.ServicesStatistics.java
/** * @see org.opencastproject.serviceregistry.impl.jmx.ServicesStatisticsMXBean#getErrorServiceCount() *///from ww w .jav a2 s.c o m @Override public int getErrorServiceCount() { return CollectionUtils.countMatches(services.values(), PredicateUtils.equalPredicate(ServiceState.ERROR)); }
From source file:org.pentaho.platform.plugin.services.pluginmgr.PluginMessageLogger.java
public static int count(final String messagePrefix) { return CollectionUtils.countMatches(messages.get(), new Predicate() { public boolean evaluate(Object object) { return ((String) object).startsWith(messagePrefix); }//from w w w. j a v a2 s . c om }); }
From source file:org.pentaho.test.platform.plugin.pluginmgr.SystemPathPluginProviderIT.java
@SuppressWarnings("deprecation") @Test/* w w w . j a va2 s. c o m*/ public void testLoadBeanDefinition() throws PlatformPluginRegistrationException { microPlatform.init(); List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession()); IPlatformPlugin plugin = (IPlatformPlugin) CollectionUtils.find(plugins, new PluginNameMatcherPredicate("Plugin 1")); assertNotNull("Plugin 1 should have been found", plugin); Collection<PluginBeanDefinition> beans = plugin.getBeans(); assertEquals("FooComponent was not loaded", 1, CollectionUtils.countMatches(beans, new Predicate() { public boolean evaluate(Object object) { PluginBeanDefinition bean = (PluginBeanDefinition) object; return bean.getBeanId().equals("FooComponent") && bean.getClassname().equals("org.pentaho.test.platform.plugin.pluginmgr.FooComponent"); } })); assertEquals("genericBean was not loaded", 1, CollectionUtils.countMatches(beans, new Predicate() { public boolean evaluate(Object object) { PluginBeanDefinition bean = (PluginBeanDefinition) object; return bean.getBeanId().equals("genericBean") && bean.getClassname().equals("java.lang.Object"); } })); }
From source file:org.pentaho.test.platform.plugin.pluginmgr.SystemPathPluginProviderIT.java
@SuppressWarnings("deprecation") @Test/*from w w w .j a va 2 s .c o m*/ public void testLoadContentGenerators() throws PlatformPluginRegistrationException { microPlatform.init(); List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession()); IPlatformPlugin plugin = (IPlatformPlugin) CollectionUtils.find(plugins, new PluginNameMatcherPredicate("content-generator-plugin")); assertNotNull("content-generator-plugin should have been found", plugin); List<IContentInfo> contentTypes = plugin.getContentInfos(); Object contentType = CollectionUtils.find(contentTypes, new Predicate() { public boolean evaluate(Object object) { IContentInfo type = (IContentInfo) object; return type.getTitle().equals("Good Test Type"); } }); assertNotNull("\"Good Test Type\" should have been loaded", contentType); assertNotNull("\"Good Test Type\" extension definition is incorrect", ((IContentInfo) contentType).getExtension().equals("good-content-type")); IContentInfo contentInfo = (IContentInfo) contentType; IPluginOperation operation = contentInfo.getOperations().listIterator().next(); assertEquals("Missing perspective", "custom-perspective", operation.getPerspective()); assertEquals("\"Test Type Missing type\" should not have been loaded", 0, CollectionUtils.countMatches(contentTypes, new Predicate() { public boolean evaluate(Object object) { IContentInfo type = (IContentInfo) object; return type.getTitle().equals("Test Type Missing type"); } })); assertEquals("\"test-type-missing-title\" should not have been loaded", 0, CollectionUtils.countMatches(contentTypes, new Predicate() { public boolean evaluate(Object object) { IContentInfo type = (IContentInfo) object; return type.getExtension().equals("test-type-missing-title"); } })); }
From source file:org.sipfoundry.sipxconfig.admin.commserver.RegistrationMetrics.java
public int getActiveRegistrationCount() { int count = CollectionUtils.countMatches(m_uniqueRegistrations, new ActiveRegistrations(m_startTime)); return count; }
From source file:org.xlcloud.console.entitlements.ExplicitEntitlementDictionary.java
private boolean forAllActions(Predicate predicate) { return (CollectionUtils.countMatches(actions, predicate) == actions.size()); }
From source file:org.xlcloud.console.entitlements.nodes.EntitlementNode.java
private boolean forAllChildren(Predicate predicate) { return (CollectionUtils.countMatches(getChildren(), predicate) == getChildCount()); }
From source file:pt.webdetails.cns.service.store.DefaultVolatileStorage.java
public int getTotalCount(String user, String[] roles, boolean unreadOnly) { int totalCount = 0; if (StringUtils.isEmpty(user)) { return totalCount; } else if (unreadOnly) { totalCount = CollectionUtils.countMatches(publicStorage, UNREAD_FILTER); totalCount += CollectionUtils.countMatches(userStorage.get(user), UNREAD_FILTER); if (roles != null) { for (String role : roles) { totalCount += CollectionUtils.countMatches(roleStorage.get(role), UNREAD_FILTER); }/*from ww w . j a va2 s. c o m*/ } } else { totalCount = publicStorage != null ? publicStorage.size() : 0; totalCount += userStorage.get(user) != null ? userStorage.get(user).size() : 0; if (roles != null) { for (String role : roles) { totalCount += roleStorage.get(role) != null ? roleStorage.get(role).size() : 0; } } } return totalCount; }