List of usage examples for org.apache.commons.collections CollectionUtils find
public static Object find(Collection collection, Predicate predicate)
From source file:net.sourceforge.fenixedu.domain.messaging.AnnouncementCategoryType.java
public static AnnouncementCategory getAnnouncementCategoryByType(final AnnouncementCategoryType type) { return (AnnouncementCategory) CollectionUtils.find(Bennu.getInstance().getCategoriesSet(), new Predicate() { @Override//from ww w.j a va 2s . c o m public boolean evaluate(Object arg0) { return ((AnnouncementCategory) arg0).getType().equals(type); } }); }
From source file:com.codenjoy.dojo.tetris.model.TestUtils.java
public static void assertContainsPlot(final int x, final int y, final PlotColor color, List<Plot> plots) { Object foundPlot = CollectionUtils.find(plots, new Predicate() { @Override/*from w w w .ja va2 s. co m*/ public boolean evaluate(Object object) { Plot plot = (Plot) object; return plot.getColor() == color && plot.getX() == x && plot.getY() == y; } }); assertNotNull("Plot with coordinates (" + x + "," + y + ") color: " + color + " not found", foundPlot); }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.resourceAllocationManager.RemoverTurno.java
@Atomic public static Object run(final InfoShift infoShift, final InfoClass infoClass) { check(RolePredicates.RESOURCE_ALLOCATION_MANAGER_PREDICATE); final Shift shift = FenixFramework.getDomainObject(infoShift.getExternalId()); if (shift == null) { return Boolean.FALSE; }/*from w w w . j a va 2 s . co m*/ final SchoolClass schoolClass = (SchoolClass) CollectionUtils.find(shift.getAssociatedClassesSet(), new Predicate() { @Override public boolean evaluate(Object arg0) { final SchoolClass schoolClass = (SchoolClass) arg0; return schoolClass.getExternalId().equals(infoClass.getExternalId()); } }); if (schoolClass == null) { return Boolean.FALSE; } shift.getAssociatedClassesSet().remove(schoolClass); return Boolean.TRUE; }
From source file:com.codenjoy.dojo.tetris.model.TestUtils.java
public static void assertContainsPlot(final int x, final int y, List<Plot> plots) { Object foundPlot = CollectionUtils.find(plots, new Predicate() { @Override/*w ww . j a v a 2 s. com*/ public boolean evaluate(Object object) { Plot plot = (Plot) object; return plot.getX() == x && plot.getY() == y; } }); assertNotNull("Plot with coordinates (" + x + "," + y + ") not found", foundPlot); }
From source file:net.sourceforge.fenixedu.domain.accounting.events.export.SIBSOutgoingPaymentQueueJob.java
public static SIBSOutgoingPaymentQueueJob getQueueJobNotDoneAndNotCancelled() { List<SIBSOutgoingPaymentQueueJob> jobList = readAllSIBSOutgoingPaymentQueueJobs(); return (SIBSOutgoingPaymentQueueJob) CollectionUtils.find(jobList, new Predicate() { @Override/*from ww w. ja va 2 s . com*/ public boolean evaluate(Object arg0) { return ((QueueJob) arg0).getIsNotDoneAndNotCancelled(); } }); }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.teacher.onlineTests.DeleteTestQuestion.java
protected void run(String executionCourseId, String testId, final String questionId) throws InvalidArgumentsServiceException { Test test = FenixFramework.getDomainObject(testId); if (test == null) { throw new InvalidArgumentsServiceException(); }// w w w.j av a 2s . com TestQuestion testQuestion = (TestQuestion) CollectionUtils.find(test.getTestQuestionsSet(), new Predicate() { @Override public boolean evaluate(Object arg0) { final TestQuestion testQuestion = (TestQuestion) arg0; return testQuestion.getQuestion().getExternalId().equals(questionId); } }); if (testQuestion == null) { throw new InvalidArgumentsServiceException(); } test.deleteTestQuestion(testQuestion); }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.coordinator.ReadCurrentExecutionDegreeByDegreeCurricularPlanID.java
protected InfoExecutionDegree run(final String degreeCurricularPlanID) { final DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID); final Collection executionDegrees = degreeCurricularPlan.getExecutionDegreesSet(); final ExecutionDegree executionDegree = (ExecutionDegree) CollectionUtils.find(executionDegrees, new Predicate() { @Override//from w w w. java 2 s . c om public boolean evaluate(Object arg0) { final ExecutionDegree executionDegree = (ExecutionDegree) arg0; return executionDegree.getExecutionYear().isCurrent(); } }); return InfoExecutionDegree.newInfoFromDomain(executionDegree); }
From source file:de.forsthaus.backend.dao.impl.LanguageDAOImpl.java
@Override public Language getLanguageById(final int lan_id) { return (Language) CollectionUtils.find(LANGUAGES, new Predicate() { @Override/*from w w w. j a v a2 s . com*/ public boolean evaluate(Object object) { return lan_id == ((Language) object).getId(); } }); }
From source file:com.ikon.servlet.frontend.ThesaurusServlet.java
@Override public List<String> getKeywords(final String filter) throws OKMException { log.debug("getKeywords({})", filter); List<String> keywordList = new ArrayList<String>(); List<String> keywords = RDFREpository.getInstance().getKeywords(); int index = -1; int size = keywords.size(); updateSessionManager();//w w w .j a v a 2 s.co m // Keywords list is an ordered list String value = (String) CollectionUtils.find(keywords, new Predicate() { @Override public boolean evaluate(Object arg0) { String key = (String) arg0; if (key.toLowerCase().startsWith(filter)) { return true; } else { return false; } } }); if (value != null) { index = keywords.indexOf(value); } if (index >= 0) { while (size > index && keywords.get(index).toLowerCase().startsWith(filter)) { keywordList.add(keywords.get(index)); index++; } } log.debug("getKeywords: {}", keywordList); return keywordList; }
From source file:de.hybris.platform.security.captcha.ReCaptchaAspect.java
public Object prepare(final ProceedingJoinPoint joinPoint) throws Throwable { final List<Object> args = Arrays.asList(joinPoint.getArgs()); final HttpServletRequest request = (HttpServletRequest) CollectionUtils.find(args, PredicateUtils.instanceofPredicate(HttpServletRequest.class)); if (request != null) { final boolean captcaEnabledForCurrentStore = isCaptcaEnabledForCurrentStore(); request.setAttribute("captcaEnabledForCurrentStore", Boolean.valueOf(captcaEnabledForCurrentStore)); if (captcaEnabledForCurrentStore) { request.setAttribute("recaptchaPublicKey", getSiteConfigService().getProperty(RECAPTCHA_PUBLIC_KEY_PROPERTY)); }/*from www. ja v a 2 s .c o m*/ } return joinPoint.proceed(); }