List of usage examples for org.apache.commons.collections Predicate Predicate
Predicate
From source file:com.newlandframework.avatarmq.consumer.ConsumerClusters.java
public RemoteChannelData nextRemoteChannelData() { Predicate predicate = new Predicate() { public boolean evaluate(Object object) { RemoteChannelData data = (RemoteChannelData) object; Channel channel = data.getChannel(); return NettyUtil.validateChannel(channel); }/*from ww w . j av a2s.co m*/ }; CollectionUtils.filter(channelList, predicate); return channelList.get(next++ % channelList.size()); }
From source file:edu.kit.rest.usergroupmanagement.test.UserGroupTestService.java
private UserData findUserById(final Long id) { return (UserData) CollectionUtils.find(users, new Predicate() { @Override/*from w w w . j av a 2s . com*/ public boolean evaluate(Object o) { return Objects.equals(((UserData) o).getUserId(), id); } }); }
From source file:net.sourceforge.fenixedu.domain.phd.PhdProgramFocusArea.java
public List<ExternalPhdProgram> getAssociatedExternalPhdProgramsForCollaborationType( final PhdIndividualProgramCollaborationType type) { List<ExternalPhdProgram> externalPhdProgramList = new ArrayList<ExternalPhdProgram>(); CollectionUtils.select(getExternalPhdProgramsSet(), new Predicate() { @Override/*from w w w. ja va 2s.com*/ public boolean evaluate(Object object) { return ((ExternalPhdProgram) object).isForCollaborationType(type); } }, externalPhdProgramList); return externalPhdProgramList; }
From source file:ml.shifu.shifu.actor.worker.DataFilterWorker.java
/** * Filter the data - it uses @dataPurifier to filter data * * @param inputDataList - input data to filter *//*from w w w .j ava 2s . c om*/ private void purifyData(List<String> inputDataList) { log.info("starting to filter data ... "); CollectionUtils.filter(inputDataList, new Predicate() { @Override public boolean evaluate(Object object) { String inputData = (String) object; return dataPurifier.isFilter(inputData); } }); log.info("there are {} records after filter.", inputDataList.size()); }
From source file:module.siadap.domain.ExceedingQuotaProposal.java
public static List<ExceedingQuotaProposal> getQuotaProposalsFor(final Unit unit, int year) { //let's go through the SiadapYearConfiguration List<ExceedingQuotaProposal> exceedingQuotaProposalsToReturn = new ArrayList<ExceedingQuotaProposal>(); SiadapYearConfiguration configuration = SiadapYearConfiguration.getSiadapYearConfiguration(year); if (configuration == null) { return exceedingQuotaProposalsToReturn; }/* w ww. j a v a 2s. c o m*/ return getQuotaProposalsByPredicate(configuration.getExceedingQuotasProposals(), new Predicate() { @Override public boolean evaluate(Object arg0) { ExceedingQuotaProposal exceedingQuotaProposal = (ExceedingQuotaProposal) arg0; return (exceedingQuotaProposal.getUnit().equals(unit)); } }); }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.masterDegree.commons.candidate.WriteCandidateEnrolments.java
protected void run(Set<String> selectedCurricularCoursesIDs, String candidateID, Double credits, String givenCreditsRemarks) throws FenixServiceException { MasterDegreeCandidate masterDegreeCandidate = FenixFramework.getDomainObject(candidateID); if (masterDegreeCandidate == null) { throw new NonExistingServiceException(); }//from w w w .j a v a 2 s.co m masterDegreeCandidate.setGivenCredits(credits); if (credits.floatValue() != 0) { masterDegreeCandidate.setGivenCreditsRemarks(givenCreditsRemarks); } Collection<CandidateEnrolment> candidateEnrolments = masterDegreeCandidate.getCandidateEnrolmentsSet(); List<String> candidateEnrolmentsCurricularCoursesIDs = (List<String>) CollectionUtils .collect(candidateEnrolments, new Transformer() { @Override public Object transform(Object arg0) { CandidateEnrolment candidateEnrolment = (CandidateEnrolment) arg0; return candidateEnrolment.getCurricularCourse().getExternalId(); } }); Collection<String> curricularCoursesToEnroll = CollectionUtils.subtract(selectedCurricularCoursesIDs, candidateEnrolmentsCurricularCoursesIDs); final Collection<Integer> curricularCoursesToDelete = CollectionUtils .subtract(candidateEnrolmentsCurricularCoursesIDs, selectedCurricularCoursesIDs); Collection<CandidateEnrolment> candidateEnrollmentsToDelete = CollectionUtils.select(candidateEnrolments, new Predicate() { @Override public boolean evaluate(Object arg0) { CandidateEnrolment candidateEnrolment = (CandidateEnrolment) arg0; return (curricularCoursesToDelete .contains(candidateEnrolment.getCurricularCourse().getExternalId())); } }); writeFilteredEnrollments(masterDegreeCandidate, curricularCoursesToEnroll); for (CandidateEnrolment candidateEnrolmentToDelete : candidateEnrollmentsToDelete) { candidateEnrolmentToDelete.delete(); } }
From source file:flex2.compiler.mxml.rep.Array.java
/** * Note that we do *not* filter out bindings for element initializers. *//*from ww w .j a va 2 s . c o m*/ @SuppressWarnings("unchecked") public final Iterator<ArrayElementInitializer> getElementInitializerIterator() { return new FilterIterator(list.iterator(), new Predicate() { public boolean evaluate(Object object) { return (!(((ArrayElementInitializer) object).getValue() instanceof Reparent)); } }); }
From source file:net.sourceforge.fenixedu.domain.candidacyProcess.erasmus.ApprovedLearningAgreementDocumentFile.java
protected List<ApprovedLearningAgreementExecutedAction> getSentLearningAgreementActions() { List<ApprovedLearningAgreementExecutedAction> executedActionList = new ArrayList<ApprovedLearningAgreementExecutedAction>(); CollectionUtils.select(getExecutedActionsSet(), new Predicate() { @Override/*from w w w . j av a 2 s.c om*/ public boolean evaluate(Object arg0) { return ((ApprovedLearningAgreementExecutedAction) arg0).isSentLearningAgreementAction(); }; }, executedActionList); Collections.sort(executedActionList, Collections.reverseOrder(ExecutedAction.WHEN_OCCURED_COMPARATOR)); return executedActionList; }
From source file:de.softwareforge.pgpsigner.key.PublicKeyRing.java
public PublicKeyRing getSignedKeys() { return processMap(new Predicate() { public boolean evaluate(Object o) { return ((PublicKey) o).isSigned(); }//from www . j a v a 2 s. co m }); }
From source file:com.webcrawler.MailCrawlerService.java
/** * Gets the link filter predicate./*from ww w .j a v a 2 s.co m*/ * * @param shouldVisitPattern the should visit pattern * @return the link filter predicate */ private Predicate getLinkFilterPredicate(final String shouldVisitPattern) { return new Predicate() { public boolean evaluate(Object arg0) { Pattern pattern = Pattern.compile(shouldVisitPattern); Element linkElement = (Element) arg0; String absoluteUrl = linkElement.attr("abs:href"); Matcher matcher = pattern.matcher(absoluteUrl); if (matcher.find()) { if (MailCrawlerService.log.isDebugEnabled()) { MailCrawlerService.log.debug("Should be visited: " + absoluteUrl); } return true; } if (MailCrawlerService.log.isDebugEnabled()) { MailCrawlerService.log.debug("Should not be visited: " + absoluteUrl); } return false; } }; }