List of usage examples for org.apache.commons.collections Predicate Predicate
Predicate
From source file:com.linkedin.thirdeye.hadoop.util.ThirdeyeAvroUtils.java
/** * Helper removed from AvroRecordReader in b19a0965044d3e3f4f1541cc4cd9ea60b96a4b99 * * @param fieldSchema//w ww .j a v a2s . com * @return */ private static org.apache.avro.Schema extractSchemaFromUnionIfNeeded(org.apache.avro.Schema fieldSchema) { if ((fieldSchema).getType() == Schema.Type.UNION) { fieldSchema = ((org.apache.avro.Schema) CollectionUtils.find(fieldSchema.getTypes(), new Predicate() { @Override public boolean evaluate(Object object) { return ((org.apache.avro.Schema) object).getType() != Schema.Type.NULL; } })); } return fieldSchema; }
From source file:bard.pubchem.model.PCAssayPanel.java
public XRef getTaxonomy() { List<PCAssayXRef> list = new ArrayList<PCAssayXRef>(); CollectionUtils.select(assay.getAssayXRefs(), new Predicate() { public boolean evaluate(Object object) { PCAssayXRef xref = (PCAssayXRef) object; if (xref.getPanel() != null) if (xref.getPanel().getPanelNumber() == getPanelNumber()) if (xref.getXRef() != null && "taxonomy".equals(xref.getXRef().getDatabase())) return true; return false; }/*from www. j av a2s . co m*/ }, list); return list.size() > 0 ? list.get(0).getXRef() : null; }
From source file:net.sourceforge.fenixedu.domain.student.importation.ExportDegreeCandidaciesByDegreeForPasswordGeneration.java
public static List<ExportDegreeCandidaciesByDegreeForPasswordGeneration> readAllJobs( final ExecutionYear executionYear) { List<ExportDegreeCandidaciesByDegreeForPasswordGeneration> jobList = new ArrayList<ExportDegreeCandidaciesByDegreeForPasswordGeneration>(); CollectionUtils.select(executionYear.getDgesBaseProcessSet(), new Predicate() { @Override//from w w w . jav a 2 s . co m public boolean evaluate(Object arg0) { return arg0 instanceof ExportDegreeCandidaciesByDegreeForPasswordGeneration; } }, jobList); return jobList; }
From source file:edu.kit.sharing.test.SharingTestService.java
@Override public Response deleteReference(String pDomain, String pDomainUniqueId, String pGroupId, HttpContext hc) { final SecurableResourceId rid = new SecurableResourceId(pDomain, pDomainUniqueId); final GroupId gid = new GroupId(pGroupId); ReferenceId rr = (ReferenceId) CollectionUtils.find(references, new Predicate() { @Override//from w ww .ja v a 2 s .c o m public boolean evaluate(Object o) { ReferenceId r = (ReferenceId) o; return r.getSecurableResourceId() == rid && r.getGroupId() == gid; } }); references.remove(rr); return Response.ok().build(); }
From source file:gov.nih.nci.cabig.caaers.domain.AdditionalInformationDocument.java
public static Map<String, List<AdditionalInformationDocument>> groupDocumentsByDocumentType( List<AdditionalInformationDocument> additionalInformationDocuments) { Map<String, List<AdditionalInformationDocument>> documents = new HashMap<String, List<AdditionalInformationDocument>>(); for (final AdditionalInformationDocumentType documentType : AdditionalInformationDocumentType.values()) { List<AdditionalInformationDocument> select = new ArrayList<AdditionalInformationDocument>(); CollectionUtils.select(additionalInformationDocuments, new Predicate() { public boolean evaluate(Object o) { AdditionalInformationDocument additionalInformationDocument = (AdditionalInformationDocument) o; return additionalInformationDocument.getAdditionalInformationDocumentType() .equals(documentType); }//from www . j a v a 2s .c o m }, select); if (!select.isEmpty()) { documents.put(String.format("%s", documentType.getCode()), select); } } return documents; }
From source file:hr.fer.zemris.vhdllab.service.workspace.ProjectMetadataTest.java
@Test public void addFile3() { File file = new File("file_name", null, "data"); metadata.addFile(file);/* w w w .ja v a 2 s . co m*/ File found = (File) CollectionUtils.find(metadata.getFiles(), new Predicate() { @Override public boolean evaluate(Object object) { File f = (File) object; return f.getName().equals("file_name"); } }); assertEquals(hierarchy.getProject(), found.getProject()); }
From source file:net.sourceforge.fenixedu.domain.Branch.java
private Boolean hasCurricularCourseCommonBranchInAnyCurricularCourseScope(CurricularCourse curricularCourse, final Branch commonBranch) { return ((CurricularCourseScope) CollectionUtils.find(curricularCourse.getScopesSet(), new Predicate() { @Override//from w ww. j a v a 2 s .c om public boolean evaluate(Object o) { CurricularCourseScope ccs = (CurricularCourseScope) o; return ccs.getBranch().equals(commonBranch); } }) != null); }
From source file:edu.kit.dama.ui.simon.panel.SimonMainPanel.java
/** * Reload the view and refresh the status of all probes. *//* ww w.j a va2 s.c om*/ private void reload() { LOGGER.debug("Reloading main panel"); //remove all tabs and clear all categories for (Tab tab : tabs) { tabSheet.removeTab(tab); probesByCategory.clear(); tabsByCategory.clear(); } //get all probes AbstractProbe[] probes = SimonConfigurator.getSingleton().getProbes(); LOGGER.debug(" - Obtaining categories for {} probes", probes.length); for (AbstractProbe probe : probes) { //refresh the status probe.refreshProbeStatus(); //obtain category and assign probe to according list String currentProbesCategory = probe.getCategory(); List<AbstractProbe> probesInCategory = probesByCategory.get(currentProbesCategory); if (probesInCategory == null) { LOGGER.debug(" - Obtained new category {}", currentProbesCategory); probesInCategory = new LinkedList<>(); probesInCategory.add(probe); LOGGER.debug(" - Adding probe {} to new category", probe.getName()); probesByCategory.put(currentProbesCategory, probesInCategory); } else { LOGGER.debug(" - Adding probe {} to existing category {}", new Object[] { probe.getName(), currentProbesCategory }); probesInCategory.add(probe); } } //sort all category keys by name Set<String> keys = probesByCategory.keySet(); String[] aKeys = keys.toArray(new String[keys.size()]); Arrays.sort(aKeys); LOGGER.debug(" - Building category tabs"); for (String key : aKeys) { tabsByCategory.put(key, createCategoryTab(probesByCategory.get(key))); } tabsByCategory.put("Overview", buildOverviewTab(aKeys)); tabs.add(tabSheet.addTab(tabsByCategory.get("Overview"), "Overview")); for (String key : aKeys) { Tab categoryTab = tabSheet.addTab(tabsByCategory.get(key), key); List<AbstractProbe> probeList = probesByCategory.get(key); if (CollectionUtils.find(probeList, new Predicate() { @Override public boolean evaluate(Object o) { return ((AbstractProbe) o).getCurrentStatus().equals(AbstractProbe.PROBE_STATUS.FAILED); } }) != null) { categoryTab.setIcon(new ThemeResource("img/icons/warning.png")); } tabs.add(categoryTab); } LOGGER.debug("Layout successfully created."); }
From source file:module.mailtracking.domain.Year.java
public java.util.List<CorrespondenceEntry> getAbleToViewEntries(final CorrespondenceType type, boolean onlyActive) { java.util.List<CorrespondenceEntry> entries = new java.util.ArrayList<CorrespondenceEntry>(); java.util.List<CorrespondenceEntry> baseEntries = onlyActive ? getActiveEntries(type) : getAnyStateEntries(type);/*from w ww. ja va2 s . co m*/ CollectionUtils.select(baseEntries, new Predicate() { @Override public boolean evaluate(Object arg0) { return ((CorrespondenceEntry) arg0).isUserAbleToView(Authenticate.getUser()); } }, entries); return entries; }
From source file:com.ibm.bluej.commonutil.visualization.PrintableVisualizationViewer.java
protected void setStandardOptions() { PluggableRenderer r = (PluggableRenderer) this.getRenderer(); r.setVertexStringer(new StringVertexStringer()); r.setEdgeStringer(new StringEdgeStringer()); r.setEdgeShapeFunction(new SpacedCurve()); r.setVertexPaintFunction(new SmartVertexPaintFunction(r, callbacks)); r.setEdgeLabelClosenessFunction(new ConstantEdgeValue(.5)); r.setEdgePaintFunction(new SmartEdgePaintFunction(r, callbacks)); r.setEdgeFontFunction(new FontHandler()); this.setDoubleBuffered(true); DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); this.setGraphMouse(graphMouse); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); this.getPickedState().addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getItem() instanceof LabeledDirectedSparseVertex) { LabeledDirectedSparseVertex v = (LabeledDirectedSparseVertex) e.getItem(); if (e.getStateChange() == ItemEvent.SELECTED) { callbacks.picked((T) v.marked); return; }/*from w w w . j av a2 s. co m*/ if (e.getStateChange() == ItemEvent.DESELECTED) { callbacks.unpicked((T) v.marked); return; } System.err.println(e.toString()); System.err.println(e.getItem().toString()); } else { LabeledDirectedSparseEdge edge = (LabeledDirectedSparseEdge) e.getItem(); if (e.getStateChange() == ItemEvent.SELECTED) { callbacks.picked((T) edge.getFrom(), edge.getLabel(), (T) edge.getTo()); return; } if (e.getStateChange() == ItemEvent.DESELECTED) { callbacks.unpicked((T) edge.getFrom(), edge.getLabel(), (T) edge.getTo()); return; } System.out.println("Edge pick"); System.out.println(e.getItem().getClass().getName()); System.out.println(e.getStateChange()); } } }); setToolTipFunction(new DefaultToolTipFunction() { public String getToolTipText(Vertex v) { return callbacks.getToolTip((T) ((LabeledDirectedSparseVertex) v).marked); } /* public String getToolTipText(Edge edge) { edu.uci.ics.jung.utils.Pair accts = edge.getEndpoints(); Vertex v1 = (Vertex) accts.getFirst(); Vertex v2 = (Vertex) accts.getSecond(); return v1 + " -- " + v2; } */ }); Predicate p = new Predicate() { public boolean evaluate(Object arg0) { if (!(arg0 instanceof LabeledDirectedSparseEdge)) { System.err.println("Unexpected: " + arg0); return false; } LabeledDirectedSparseEdge edge = (LabeledDirectedSparseEdge) arg0; return callbacks.shouldShowEdge((T) edge.getFrom(), edge.getLabel(), (T) edge.getTo()); } }; r.setEdgeIncludePredicate(p); this.setPickSupport(new ShapePickSupport(4)); //System.out.println(getPickSupport().getClass().getName()); }