List of usage examples for org.apache.commons.collections CollectionUtils select
public static Collection select(Collection inputCollection, Predicate predicate)
From source file:org.dentaku.gentaku.tools.cgen.visitor.PluginOutputVisitor.java
/** * Returns all model objects (read: candidates) that are in a specified location and containing a tag with the specified prefix * * @param location Specifies the model base class to search through * @param prefix Node is selected if it contains a tag of that prefix * @param parent ModelElement in the UML model that we are currently considering * @return Nodes matching criteria//from w w w . j a va2s .c om */ private Collection findElementsForLocationAndPrefix(String location, final String prefix, final ModelElement parent) { // special case if parent is not an element container, the list of candidate elements is just this element if (parent != null && !(parent instanceof Namespace)) { return Collections.singletonList(parent); } Collection elements = getCandidateElementsForLocation(location); Collection result = CollectionUtils.select(elements, new Predicate() { public boolean evaluate(Object object) { ModelElement candidate = (ModelElement) object; if (notTheDroidsYoureLookingFor(candidate, parent) || (candidate instanceof HashMap)) { return false; } Collection c = candidate.getTaggedValue(); for (Iterator it = c.iterator(); it.hasNext();) { TaggedValue taggedValue = (TaggedValue) it.next(); if (taggedValue.getName().startsWith(prefix)) { return true; } } return false; } }); return result; }
From source file:org.eclipse.wb.internal.layout.group.model.GroupLayoutSupport.java
/** * @return the list of non-deleted children of this container. *//*from w ww .jav a 2s . co m*/ @SuppressWarnings("unchecked") public final List<AbstractComponentInfo> getLayoutChildren() { return (List<AbstractComponentInfo>) CollectionUtils.select(getComponents(), new Predicate() { public boolean evaluate(Object object) { JavaInfo javaInfo = (JavaInfo) object; return !javaInfo.isDeleted() && !javaInfo.isDeleting(); } }); }
From source file:org.eclipse.wb.internal.swing.preferences.laf.LafPreferencePage.java
/** * Deletes (or permanently hide) LAF and store LAF list into persistence. *//*w ww .j ava 2 s .c o m*/ @SuppressWarnings("unchecked") private void handleDelete() { List<Object> selection = getSelectedEntries(); if (selection.contains(m_defaultLAF)) { MessageDialog.openWarning(getShell(), Messages.LafPreferencePage_deleteWarningTitle, Messages.LafPreferencePage_deleteWarningMessage); // filter out default LAF selection = (List<Object>) CollectionUtils.select(selection, new Predicate() { public boolean evaluate(Object object) { return object != m_defaultLAF; } }); } if (!selection.isEmpty()) { if (MessageDialog.openConfirm(getShell(), Messages.LafPreferencePage_deleteConfirmTitle, MessageFormat.format(Messages.LafPreferencePage_deleteConfirmMessage, selection.size()))) { for (Object entry : selection) { if (entry instanceof CategoryInfo) { commands_add(new RemoveCategoryCommand((CategoryInfo) entry)); } else if (entry instanceof LafInfo) { commands_add(new RemoveCommand((LafInfo) entry)); } } refreshViewer(); } } }
From source file:org.eclipse.wb.internal.swt.model.layout.form.FormDataInfo.java
/** * Creates the {@link ComplexProperty} for {@link FormAttachmentInfo} by attachment's property * name./*w ww . j av a 2 s. c o m*/ */ private ComplexProperty createAttachmentProperty(int side, String title) throws Exception { final FormAttachmentInfo attachment = getAttachment(side); ComplexProperty attachmentProperty = new ComplexProperty(title, attachment.toString()) { @Override public void setValue(Object value) throws Exception { if (value == Property.UNKNOWN_VALUE) { attachment.delete(); } } }; Collection<?> selectedProperties = CollectionUtils.select(Arrays.asList(attachment.getProperties()), new Predicate() { public boolean evaluate(Object object) { Property property = (Property) object; return !property.getTitle().equals("Class") && !property.getTitle().equals("Constructor"); } }); attachmentProperty.setProperties(selectedProperties.toArray(new Property[selectedProperties.size()])); return attachmentProperty; }
From source file:org.egov.works.abstractestimate.entity.AbstractEstimate.java
public Collection<Activity> getSORActivities() { return CollectionUtils.select(activities, activity -> ((Activity) activity).getSchedule() != null); }
From source file:org.egov.works.abstractestimate.entity.AbstractEstimate.java
public Collection<Activity> getNonSORActivities() { return CollectionUtils.select(activities, activity -> ((Activity) activity).getNonSor() != null); }
From source file:org.egov.works.models.estimate.EstimateTemplate.java
public Collection<EstimateTemplateActivity> getSORActivities() { return CollectionUtils.select(estimateTemplateActivities, activity -> ((EstimateTemplateActivity) activity).getSchedule() != null); }
From source file:org.egov.works.models.estimate.EstimateTemplate.java
public Collection<EstimateTemplateActivity> getNonSORActivities() { return CollectionUtils.select(estimateTemplateActivities, activity -> ((EstimateTemplateActivity) activity).getNonSor() != null); }
From source file:org.egov.works.models.tender.TenderResponseActivity.java
public Collection<TenderResponseQuotes> getTenderResponseQuotesList() { return CollectionUtils.select(tenderResponseQuotes, tenderReponseQuote -> (TenderResponseQuotes) tenderReponseQuote != null); }
From source file:org.egov.works.services.impl.ContractorBillServiceImpl.java
@Override public Collection<StatutoryDeductionsForBill> getStatutoryDeductions( final List<StatutoryDeductionsForBill> actionStatutorydetails) { return CollectionUtils.select(actionStatutorydetails, statutoryDeductionsForBill -> (StatutoryDeductionsForBill) statutoryDeductionsForBill != null); }