List of usage examples for org.apache.commons.collections Predicate Predicate
Predicate
From source file:net.sf.wickedshell.util.ShellViewUtil.java
@SuppressWarnings("unchecked") public static final ShellView selectTargetFromAvailable(String action, final IShellViewFilter filter, boolean provideNewShell) { ShellView targetShellView = null;/* w w w . j a va 2 s . c o m*/ List applicableRegisteredShellViews = new ArrayList( Arrays.asList(ShellPlugin.getDefault().getRegisteredShellViews())); if (filter != null) { CollectionUtils.filter(applicableRegisteredShellViews, new Predicate() { /** * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object) */ public boolean evaluate(Object object) { ShellView shellView = (ShellView) object; return filter.isApplicable(shellView); } }); } if (provideNewShell) { applicableRegisteredShellViews.add(PreferenceHelper.getActiveShellDescriptor()); } if (applicableRegisteredShellViews.size() == 1) { targetShellView = (ShellView) applicableRegisteredShellViews.get(0); } else if (applicableRegisteredShellViews.size() != 0) { ListDialog listDialog = new ListDialog(Display.getDefault().getActiveShell()); listDialog.setContentProvider(new ArrayContentProvider()); listDialog.setLabelProvider(new LabelProvider() { /** * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) */ public String getText(Object element) { StringBuffer buffer = new StringBuffer(); if (element instanceof ShellView) { ShellView shellView = (ShellView) element; buffer.append(shellView.getPartName()); buffer.append(" ["); buffer.append(shellView.getContentDescription()); buffer.append("]"); } else { IShellDescriptor shellDescriptor = (IShellDescriptor) element; buffer.append("New Shell ["); buffer.append(shellDescriptor.getName()); buffer.append("]"); } return buffer.toString(); } }); listDialog.setTitle("Wicked Shell - " + action); listDialog.setHelpAvailable(false); listDialog.setMessage("Please choose target from the available Shells."); listDialog.setInput(applicableRegisteredShellViews); listDialog.open(); Object[] result = listDialog.getResult(); if (result != null) { if (listDialog.getResult()[0] instanceof ShellView) { targetShellView = (ShellView) listDialog.getResult()[0]; } else { try { targetShellView = (ShellView) PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().showView(ShellID.SHELL_VIEW_ID, String.valueOf(System.currentTimeMillis()), IWorkbenchPage.VIEW_ACTIVATE); } catch (PartInitException exception) { exception.printStackTrace(); } } } } return targetShellView; }
From source file:com.exxonmobile.ace.hybris.storefront.security.ExcludeUrlRequestMatcher.java
@Override public boolean matches(final HttpServletRequest request) { // Do not match patterns specified in the excludeUrlSet to the servletPath return !CollectionUtils.exists(this.excludeUrlSet, new Predicate() { @Override//from w w w .jav a 2 s . co m public boolean evaluate(final Object excludeUrl) { return pathMatcher.match((String) excludeUrl, request.getServletPath()); } }); }
From source file:filter.ccimpl.CCFilter.java
public String[] filter(String[] values, final String prefix) { if (values == null) { return null; }//from w ww.j ava2s .c om if (prefix == null) { return values; } List result = new ArrayList(Arrays.asList(values)); CollectionUtils.filter(result, new Predicate() { public boolean evaluate(Object o) { return o != null && o.toString().startsWith(prefix); } }); return (String[]) result.toArray(new String[result.size()]); }
From source file:com.cognifide.cq.cqsm.core.scripts.ScriptFilters.java
public static Predicate filterOnSchedule(final Date date) { return new AllPredicate(new Predicate[] { filterExecutionEnabled(true), filterByExecutionMode(ExecutionMode.ON_SCHEDULE), new Predicate() { @Override// w w w . j a v a 2s.c o m public boolean evaluate(Object o) { final Script script = (Script) o; return (script.getExecutionLast() == null) && script.getExecutionSchedule().before(date); } } }); }
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 .jav a 2 s .com public boolean evaluate(Object arg0) { return ((QueueJob) arg0).getIsNotDoneAndNotCancelled(); } }); }
From source file:com.redhat.rhn.frontend.security.BaseAuthenticationService.java
protected boolean requestURIdoesLogin(final HttpServletRequest request) { return CollectionUtils.exists(getLoginURIs(), new Predicate() { public boolean evaluate(Object uri) { return request.getRequestURI().startsWith(uri.toString()); }//from ww w . jav a 2 s. com }); }
From source file:com.dp2345.dao.impl.ParameterGroupDaoImpl.java
/** * ???//from w w w . j av a 2 s. c om * * @param parameterGroup * ? * @return ? */ @Override public ParameterGroup merge(ParameterGroup parameterGroup) { Assert.notNull(parameterGroup); Set<Parameter> excludes = new HashSet<Parameter>(); CollectionUtils.select(parameterGroup.getParameters(), new Predicate() { public boolean evaluate(Object object) { Parameter parameter = (Parameter) object; return parameter != null && parameter.getId() != null; } }, excludes); List<Parameter> parameters = parameterDao.findList(parameterGroup, excludes); for (int i = 0; i < parameters.size(); i++) { Parameter parameter = parameters.get(i); String jpql = "select product from Product product join product.parameterValue parameterValue where index(parameterValue) = :parameter"; List<Product> products = entityManager.createQuery(jpql, Product.class) .setFlushMode(FlushModeType.COMMIT).setParameter("parameter", parameter).getResultList(); for (Product product : products) { product.getParameterValue().remove(parameter); if (i % 20 == 0) { super.flush(); super.clear(); } } } return super.merge(parameterGroup); }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.gep.ListMasterDegreeStudents.java
@Atomic public static Collection run(String executionYearName) { final ExecutionYear executionYear = ExecutionYear.readExecutionYearByName(executionYearName); final Collection<InfoStudentCurricularPlanWithFirstTimeEnrolment> infoStudentCurricularPlans = new ArrayList(); final Collection<StudentCurricularPlan> studentCurricularPlans = new ArrayList(); final Collection<DegreeCurricularPlan> masterDegreeCurricularPlans = DegreeCurricularPlan .readByDegreeTypeAndState(DegreeType.MASTER_DEGREE, DegreeCurricularPlanState.ACTIVE); CollectionUtils.filter(masterDegreeCurricularPlans, new Predicate() { @Override/*from w ww . j av a2 s . c om*/ public boolean evaluate(Object arg0) { DegreeCurricularPlan degreeCurricularPlan = (DegreeCurricularPlan) arg0; for (ExecutionDegree executionDegree : degreeCurricularPlan.getExecutionDegreesSet()) { if (executionDegree.getExecutionYear().equals(executionYear)) { return true; } } return false; } }); for (DegreeCurricularPlan degreeCurricularPlan : masterDegreeCurricularPlans) { studentCurricularPlans.addAll(degreeCurricularPlan.getStudentCurricularPlansSet()); } for (StudentCurricularPlan studentCurricularPlan : studentCurricularPlans) { if (!studentCurricularPlan.isActive()) { continue; } boolean firstTimeEnrolment = true; if (studentCurricularPlan.getSpecialization() != null && studentCurricularPlan.getSpecialization() .equals(Specialization.STUDENT_CURRICULAR_PLAN_MASTER_DEGREE)) { Collection<StudentCurricularPlan> previousStudentCurricularPlans = studentCurricularPlan .getRegistration().getStudentCurricularPlansBySpecialization( Specialization.STUDENT_CURRICULAR_PLAN_MASTER_DEGREE); previousStudentCurricularPlans.remove(studentCurricularPlan); for (StudentCurricularPlan previousStudentCurricularPlan : previousStudentCurricularPlans) { if (previousStudentCurricularPlan.getDegreeCurricularPlan().getDegree() .equals(studentCurricularPlan.getDegreeCurricularPlan().getDegree())) { firstTimeEnrolment = false; break; } } } else if (studentCurricularPlan.getSpecialization() != null && studentCurricularPlan .getSpecialization().equals(Specialization.STUDENT_CURRICULAR_PLAN_SPECIALIZATION)) { if (!studentCurricularPlan.getDegreeCurricularPlan().getFirstExecutionDegree().getExecutionYear() .equals(executionYear)) { continue; } } if (firstTimeEnrolment) { if (!studentCurricularPlan.getDegreeCurricularPlan().getFirstExecutionDegree().getExecutionYear() .equals(executionYear)) { firstTimeEnrolment = false; } } InfoStudentCurricularPlanWithFirstTimeEnrolment infoStudentCurricularPlan = InfoStudentCurricularPlanWithFirstTimeEnrolment .newInfoFromDomain(studentCurricularPlan); infoStudentCurricularPlan.setFirstTimeEnrolment(firstTimeEnrolment); infoStudentCurricularPlans.add(infoStudentCurricularPlan); } return infoStudentCurricularPlans; }
From source file:com.newlandframework.avatarmq.consumer.ConsumerContext.java
public static ConsumerClusters selectByClusters(String clusters) { Predicate predicate = new Predicate() { public boolean evaluate(Object object) { String id = ((ClustersRelation) object).getId(); return id.compareTo(clusters) == 0; }//from w w w .ja v a 2 s. c om }; Iterator iterator = new FilterIterator(relationArray.iterator(), predicate); ClustersRelation relation = null; while (iterator.hasNext()) { relation = (ClustersRelation) iterator.next(); break; } return (relation != null) ? relation.getClusters() : null; }
From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.choiceType.replacement.multiple.FunctionProvider.java
@Override public Object provide(Object source, Object currentValue) { return CollectionUtils.select(Bennu.getInstance().getAccountabilityTypesSet(), new Predicate() { @Override//from www . j a v a2s . c o m public boolean evaluate(Object arg0) { return isFunction((AccountabilityType) arg0); } }); }