List of usage examples for com.google.common.collect Iterables find
@Nullable public static <T> T find(Iterable<? extends T> iterable, Predicate<? super T> predicate, @Nullable T defaultValue)
From source file:org.eclipse.emf.compare.uml2.internal.postprocessor.extension.clazz.UMLGeneralizationSetChangeFactory.java
/** * {@inheritDoc}/*from ww w .j av a 2 s.c om*/ * * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getDiscriminant(org.eclipse.emf.compare.Diff) */ @Override protected EObject getDiscriminant(Diff input) { return Iterables.find(getDiscriminants(input), instanceOf(GeneralizationSet.class), null); }
From source file:org.sonar.core.test.DefaultTestable.java
public TestCase testCaseByName(final String name) { return Iterables.find(testCases(), new Predicate<TestCase>() { public boolean apply(TestCase input) { return input.name().equals(name); }//from ww w . ja v a 2s . c o m }, null); }
From source file:org.sonar.core.technicaldebt.DefaultTechnicalDebtModel.java
@Override @CheckForNull//from w w w. ja va 2s . com public DefaultCharacteristic characteristicByKey(final String key) { return Iterables.find(characteristics(), new Predicate<DefaultCharacteristic>() { @Override public boolean apply(DefaultCharacteristic input) { return input.key().equals(key); } }, null); }
From source file:msi.gama.outputs.AbstractOutputManager.java
@Override public IOutput getOutputWithOriginalName(final String s) { return Iterables.find(this, each -> each.getOriginalName().equals(s), null); }
From source file:org.asoem.greyfish.utils.collect.FunctionalFifoBuffer.java
@Override public Optional<M> findFirst(final Predicate<? super M> predicate) { return Optional.fromNullable(Iterables.find(buffer, predicate, null)); }
From source file:org.eclipse.emf.compare.uml2.internal.postprocessor.extension.UMLDirectedRelationshipFactory.java
/** * {@inheritDoc}/*from www .j a v a2s. co m*/ * * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getDiscriminant(org.eclipse.emf.compare.Diff) */ @Override protected EObject getDiscriminant(Diff input) { return Iterables.find(getDiscriminants(input), instanceOf(DirectedRelationship.class), null); }
From source file:uk.ac.stfc.isis.ibex.configserver.displaying.DisplayGroup.java
private DisplayBlock block(final String name) { return Iterables.find(allBlocks, nameMatches(name), null); }
From source file:org.jclouds.abiquo.binders.BindToPath.java
/** * Get the link to be used to build the request URI. * // w w w.j a va 2s . c o m * @param request * The current request. * @param payload * The object containing the link. * @return The link to be used to build the request URI. */ static RESTLink getLinkToUse(final GeneratedHttpRequest request, final SingleResourceTransportDto payload) { int argIndex = request.getInvocation().getArgs().indexOf(payload); Annotation[] annotations = request.getInvocation().getInvokable().getParameters().get(argIndex) .getAnnotations(); EndpointLink linkName = (EndpointLink) Iterables.find(Arrays.asList(annotations), Predicates.instanceOf(EndpointLink.class), null); if (linkName == null) { throw new BindException(request, "Expected a EndpointLink annotation but not found in the parameter"); } return checkNotNull(payload.searchLink(linkName.value()), "No link was found in object with rel: " + linkName); }
From source file:com.marvelution.bamboo.plugins.sonar.web.actions.admin.ViewSonarBuildTaskConfiguration.java
/** * Get all the {@link TaskDefinition}s available via the {@link #getPlan()} * /*from w w w . jav a 2s .com*/ * @return the {@link List} of {@link SonarConfigurationHelper} objects */ public List<SonarConfigurationHelper> getTaskDefinitions() { final List<SonarConfigurationHelper> tasks = Lists.newArrayList(); for (Job job : SonarTaskUtils.getJobsWithSonarTasks(getPlan())) { LOGGER.debug("Checking job " + job.getBuildKey() + " for Sonar Tasks"); TaskDefinition taskDefinition = Iterables.find(job.getBuildDefinition().getTaskDefinitions(), SonarPredicates.isSonarTask(), null); if (taskDefinition != null) { LOGGER.debug("Located valid Sonar Task with Id " + taskDefinition.getId()); tasks.add(new SonarConfigurationHelper(job, taskDefinition)); } } return Collections.unmodifiableList(tasks); }
From source file:org.netbeans.modules.android.maven.DalvikPlatformForMavenProvider.java
@Override public DalvikPlatform findDalvikPlatform() { NbMavenProject mvnApiPrj = p.getLookup().lookup(NbMavenProject.class); if (mvnApiPrj == null) { // weird but OK return null; }//w w w . jav a 2 s .c o m MavenProject mavenProject = mvnApiPrj.getMavenProject(); if (mavenProject == null) { LOG.log(Level.FINER, "No MavenProject for {0}", p); return null; } List<Dependency> deps = mavenProject.getDependencies(); deps = deps != null ? deps : Collections.<Dependency>emptyList(); for (Dependency d : deps) { LOG.log(Level.FINE, "dependency {0}", d); } Dependency androidDep = Iterables.find(deps, new Predicate<Dependency>() { @Override public boolean apply(Dependency d) { return ANDROID_SDK_ARTIFACT.equals(d.getArtifactId()) && ANDROID_SDK_GROUP_ID.equals(d.getGroupId()) && Artifact.SCOPE_PROVIDED.equals(d.getScope()); } }, null); if (androidDep == null) { return null; } String version = androidDep.getVersion(); LOG.log(Level.FINE, "{0} depends on android version {1}", new Object[] { p, version }); if (version == null) { return null; } for (DalvikPlatform dp : DalvikPlatformManager.getDefault().getPlatforms()) { if (dp.getAndroidTarget().getVersionName().equals(version)) { LOG.log(Level.FINE, "{0} matches to {1}", new Object[] { p, dp }); return dp; } } return null; }