List of usage examples for org.apache.commons.collections Predicate Predicate
Predicate
From source file:module.mailtracking.domain.MailTracking.java
public static Set<MailTracking> getMailTrackingsWhereUserHasSomeRole(final User user) { if (user.getPerson() == null && Group.dynamic("managers").isMember(Authenticate.getUser())) { return Bennu.getInstance().getMailTrackingsSet(); }//from w ww. j a v a 2 s .c o m java.util.Set<MailTracking> unitsWithMailTrackings = new java.util.HashSet<MailTracking>(); CollectionUtils.select(Bennu.getInstance().getMailTrackingsSet(), new Predicate() { @Override public boolean evaluate(Object arg0) { return ((MailTracking) arg0).isUserWithSomeRoleOnThisMailTracking(user); } }, unitsWithMailTrackings); return unitsWithMailTrackings; }
From source file:net.sourceforge.fenixedu.domain.teacher.TeacherService.java
public TeacherServiceNotes getTeacherServiceNotes() { return (TeacherServiceNotes) CollectionUtils.find(getServiceItemsSet(), new Predicate() { @Override/*from w ww .j a va 2 s. c o m*/ public boolean evaluate(Object arg0) { return arg0 instanceof TeacherServiceNotes; } }); }
From source file:edu.kit.dama.mdm.dataworkflow.ExecutionEnvironmentConfiguration.java
/** * Check whether this execution environment is applicable for executing the * provided configuration. The check will compare the provided * ExecutionEnvironmentProperties with the required ones defined in the * DataWorkflowConfiguration. True is returned, if the environment provides * all required properties.//from ww w.j av a 2 s . co m * * @param pConfiguration The configuration to check. * * @return TRUE if all required properties are provided. */ public boolean canExecute(DataWorkflowTaskConfiguration pConfiguration) { Set<? extends IDefaultEnvironmentProperty> required = pConfiguration.getRequiredEnvironmentProperties(); boolean result = true; for (final IDefaultEnvironmentProperty property : required) { IDefaultEnvironmentProperty providedProperty = (IDefaultEnvironmentProperty) CollectionUtils .find(providedEnvironmentProperties, new Predicate() { @Override public boolean evaluate(Object o) { return Long.compare(((IDefaultEnvironmentProperty) o).getId(), property.getId()) == 0; } }); if (providedProperty == null) { //not applicable ... Log this LOGGER.error( "Execution environment with id {} cannot handle task configuration with id {}. Property {} not supported.", getId(), pConfiguration.getId(), property); result = false; break; } } //all available return result; }
From source file:io.wcm.caconfig.extensions.persistence.impl.ToolsConfigPagePersistenceStrategy.java
/** * Searches the resource hierarchy upwards for all config references and returns them. *///from w w w.j av a2 s . c o m @SuppressWarnings("unchecked") private Iterator<String> findConfigRefs(@NotNull final Resource startResource, @NotNull final Collection<String> bucketNames) { // collect all context path resources (but filter out those without config reference) final Iterator<ContextResource> contextResources = new FilterIterator( contextPathStrategy.findContextResources(startResource), new Predicate() { @Override public boolean evaluate(Object object) { ContextResource contextResource = (ContextResource) object; return StringUtils.isNotBlank(contextResource.getConfigRef()); } }); // get config resource path for each context resource, filter out items where not reference could be resolved final Iterator<String> configPaths = new TransformIterator(contextResources, new Transformer() { @Override public Object transform(Object input) { final ContextResource contextResource = (ContextResource) input; String val = checkPath(contextResource, contextResource.getConfigRef(), bucketNames); if (val != null) { log.trace("+ Found reference for context path {}: {}", contextResource.getResource().getPath(), val); } return val; } }); return new FilterIterator(configPaths, PredicateUtils.notNullPredicate()); }
From source file:edu.kit.dama.mdm.admin.UserPropertyCollection.java
/** * Remove the property with the provided key. * * @param pKey The key of the property./*from w w w .j a v a2 s . c o m*/ * * @return TRUE if the property has been removed, FALSE if there is no * property with the provided key. */ public boolean removeProperty(final String pKey) { if (pKey == null) { throw new IllegalArgumentException("Argument pKey must not be null"); } LOGGER.debug("Removing property with key {}", pKey); UserProperty existingProp = (UserProperty) CollectionUtils.find(properties, new Predicate() { @Override public boolean evaluate(Object o) { return ((UserProperty) o).getPropertyKey().equals(pKey); } }); boolean result = true; if (existingProp != null) { properties.remove(existingProp); LOGGER.debug("Property removed"); } else { LOGGER.debug("No property found for key {}", pKey); result = false; } return result; }
From source file:net.sf.wickedshell.facade.descriptor.ExtensionShellDescriptor.java
/** * @see net.sf.wickedshell.facade.descriptor.IShellDescriptor#isExecutable(java.io.File) */// www. j a va2s . co m public boolean isExecutable(final File file) { return CollectionUtils.exists(Arrays.asList(executableFiles), new Predicate() { /** * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object) */ public boolean evaluate(Object object) { IExecutableFile executableFile = (IExecutableFile) object; return file.getName().endsWith(executableFile.getExtension()); } }); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.resourceAllocationManager.enrollments.ShiftStudentEnrollmentManagerLookupDispatchAction.java
private SchoolClass searchSchoolClassFrom(final List<SchoolClass> schoolClassesToEnrol, final String classId) { return (SchoolClass) CollectionUtils.find(schoolClassesToEnrol, new Predicate() { @Override/*from w w w .j a v a2 s .c o m*/ public boolean evaluate(Object object) { return ((SchoolClass) object).getExternalId().equals(classId); } }); }
From source file:com.linkedin.pinot.controller.helix.core.PinotHelixResourceManager.java
public List<String> getAllRealtimeTables() { List<String> ret = _helixAdmin.getResourcesInCluster(_helixClusterName); CollectionUtils.filter(ret, new Predicate() { @Override// w ww .java 2 s.c om public boolean evaluate(Object object) { if (object == null) { return false; } if (object.toString().endsWith("_" + ServerType.REALTIME.toString())) { return true; } return false; } }); return ret; }
From source file:models.Widget.java
@JsonProperty("instances") @Transient/* w ww .ja va 2 s . c o m*/ public List<WidgetInstance> getViableInstances() { if (CollectionUtils.isEmpty(instances)) { return new LinkedList<WidgetInstance>(); } List<WidgetInstance> result = new LinkedList<WidgetInstance>(instances); CollectionUtils.filter(result, new Predicate() { @Override public boolean evaluate(Object o) { return !((WidgetInstance) o).isCorrupted(); } }); return result; }
From source file:com.cyberway.issue.crawler.extractor.ExtractorHTMLTest.java
/** * Test a whitespace issue found in href. * //from w w w . j a va 2 s .c om * See [ 963965 ] Either UURI or ExtractHTML should strip whitespace better. * https://sourceforge.net/tracker/?func=detail&atid=539099&aid=963965&group_id=73833 * * @throws URIException */ public void testHrefWhitespace() throws URIException { CrawlURI curi = new CrawlURI(UURIFactory.getInstance("http://www.carsound.dk")); CharSequence cs = "<a href=\"http://www.carsound.dk\n\n\n" + "\"\ntarget=\"_blank\">C.A.R. Sound\n\n\n\n</a>"; this.extractor.extract(curi, cs); curi.getOutLinks(); assertTrue("Not stripping new lines", CollectionUtils.exists(curi.getOutLinks(), new Predicate() { public boolean evaluate(Object object) { return ((Link) object).getDestination().toString().indexOf("http://www.carsound.dk/") >= 0; } })); }