List of usage examples for com.google.common.collect Iterables find
public static <T> T find(Iterable<T> iterable, Predicate<? super T> predicate)
From source file:com.palantir.common.collect.IterableView.java
public T find(Predicate<? super T> predicate) { return Iterables.find(delegate(), predicate); }
From source file:org.richfaces.cdk.templatecompiler.statements.AddAttributesToScriptHashStatement.java
private PropertyBase findComponentAttribute(final String name) throws NoSuchElementException { return Iterables.find(componentAttributes, new NamePredicate(name)); }
From source file:org.jclouds.rimuhosting.miro.compute.functions.ServerToNodeMetadata.java
private Location findLocationWithId(final String locationId) { try {//w w w .j av a 2 s . c o m Location location = Iterables.find(locations.get(), new Predicate<Location>() { @Override public boolean apply(Location input) { return input.getId().equals(locationId); } }); return location; } catch (NoSuchElementException e) { logger.debug("couldn't match instance location %s in: %s", locationId, locations.get()); return null; } }
From source file:org.onos.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase.java
protected final <S extends SchemaNode> S firstSchemaNode(Class<S> type) { S result = null;//w w w . j a v a 2 s . c o m try { result = type.cast(Iterables.find(substatements, Predicates.instanceOf(type))); } catch (NoSuchElementException e) { result = null; } return result; }
From source file:edu.umn.msi.tropix.proteomics.rawextract.impl.RawExtractJobProcessorImpl.java
@Override protected void doPostprocessing() { if (!wasCompletedNormally()) { return;//from w w w.ja v a 2s . c om } if (producesMzxml) { final Iterable<String> resourceNames = getStagingDirectory().getResourceNames(null); final String mzxmlResource = Iterables.find(resourceNames, StringPredicates.matches(".*\\.[mM][zZ][xX][mM][lL]")); checkMzxml(mzxmlResource); final InputContext inputContext = getStagingDirectory().getInputContext(mzxmlResource); getResourceTracker().add(inputContext); } else { // Create DTAList data structure capturing all of the DTA files. LOG.debug("Creating DTAList in postprocess"); final FileDTAListImpl dtaList = new FileDTAListImpl(getStagingDirectory()); dtaList.populate(rawFileBaseName); // Convert DTA Files to MzXML LOG.debug("Converting DTAList to MzXML"); synchronized (LOCK_OBJECT) { MzXML mzxml = dtaToMzXMLConverter.dtaToMzXML(dtaList, dtaToMxXMLOptions); LOG.debug("Serializing mzxml to a temp file"); final OutputStream outputStream = getResourceTracker().newStream(); try { new MzXMLUtility().serialize(mzxml, outputStream); } finally { IO_UTILS.closeQuietly(outputStream); } mzxml = null; } } }
From source file:org.polymap.kaps.ui.form.FlurstueckSearcher.java
public void run() { try {/*from w w w . j a va 2s . c o m*/ // FlurstueckComposite template = provider.get(); // if (template != null) { // // set the search fields to the default values from the selected // // template // if (gemarkung == null) { // gemarkung = template.gemarkung().get(); // } // if (flur == null) { // flur = template.flur().get(); // } // if (nummer == null) { // nummer = template.nummer().get(); // } // if (unterNummer == null) { // unterNummer = template.unterNummer().get(); // } // } content = new ArrayList(); for (FlurstueckComposite fc : findFlurstuecke(gemarkung, flur, hauptNummer, unterNummer)) { content.add(fc); } dialog = new FlurstueckTableDialog(); dialog.setBlockOnOpen(true); if (dialog.open() == Window.OK) { assert dialog.sel.length == 1 : "Selected: " + dialog.sel.length; final IFeatureTableElement sel = dialog.sel[0]; adopt(Iterables.find(content, new Predicate<FlurstueckComposite>() { public boolean apply(FlurstueckComposite input) { return input.id().equals(sel.fid()); } })); } } catch (Exception e) { PolymapWorkbench.handleError(KapsPlugin.PLUGIN_ID, this, "Fehler beim ffnen der Flurstckstabelle.", e); } }
From source file:com.jedi.oracle.OracleCall.java
private void fillFieldValuesFromParameters() throws IllegalAccessException { List<Field> fields = FieldUtils.getFieldsListWithAnnotation(getClass(), OracleParameterMapping.class); if (fields == null || fields.isEmpty()) { return;//from w ww . j ava 2 s .c o m } for (final OracleParameter parameter : this.parameters) { switch (parameter.getDirection()) { case ReturnValue: case InputOutput: case Output: Field field = Iterables.find(fields, new Predicate<Field>() { public boolean apply(Field item) { OracleParameterMapping mapping = item.getAnnotation(OracleParameterMapping.class); return mapping.name().equals(parameter.getName()); } }); field.setAccessible(true); field.set(this, parameter.getValue()); } } }
From source file:org.jclouds.fujitsu.fgcp.compute.functions.VServerMetadataToNodeMetadata.java
protected Hardware parseHardware(String from) { try {//from w w w . j a v a 2s. com return Iterables.find(hardwares.get(), new FindHardwareForServerType(from)); } catch (NoSuchElementException e) { logger.warn("could not find a matching hardware for server type %s", from); } return null; }
From source file:org.yakindu.sct.generator.core.extensions.GeneratorExtensions.java
/** * returns the Generator Descriptor for the given generator id, or null, if * the id is unknown/*from w ww . j ava2s. com*/ */ public static IGeneratorDescriptor getGeneratorDescriptor(final String generatorId) { try { return Iterables.find(getGeneratorDescriptors(), new Predicate<IGeneratorDescriptor>() { public boolean apply(IGeneratorDescriptor input) { return input != null && input.getId() != null && input.getId().equals(generatorId); } }); } catch (NoSuchElementException ex) { return null; } }
From source file:org.jclouds.deltacloud.compute.functions.InstanceToNodeMetadata.java
protected Location parseLocation(Instance from) { try {//from ww w . j av a2 s . c o m return Iterables.find(locations.get(), new FindLocationForInstance(from)); } catch (NoSuchElementException e) { logger.warn("could not find a matching realm for instance %s", from); } return null; }