List of usage examples for com.google.common.collect Iterables filter
@GwtIncompatible("Class.isInstance") @CheckReturnValue public static <T> Iterable<T> filter(final Iterable<?> unfiltered, final Class<T> desiredType)
From source file:org.eclipse.sirius.common.tools.internal.interpreter.PolymorphicService.java
public Object call(Object[] target) throws EvaluationException { List<IMonomorphicService> candidates = Lists .newArrayList(Iterables.filter(implementers, getCompatibilityChecker(target))); if (!candidates.isEmpty()) { return candidates.get(0).call(target); } else {//from ww w. j a v a 2s . co m throw new EvaluationException( MessageFormat.format(Messages.PolymorphicService_noCompatibleImplem, getName(), target)); } }
From source file:org.linqs.psl.application.groundrulestore.MemoryGroundRuleStore.java
@Override public Iterable<WeightedGroundRule> getCompatibilityRules() { return Iterables.filter(groundRules.values(), WeightedGroundRule.class); }
From source file:org.sculptor.generator.mwe2.SculptordslValidationWorkflowComponent.java
@Override protected void invokeInternal(WorkflowContext ctx, ProgressMonitor m, Issues issues) { Collection<?> slotContent = (Collection<?>) ctx.get(getModelSlot()); if (slotContent == null) { issues.addError(String.format("Slot %s is empty", getModelSlot())); } else {/*w w w. j av a 2s . c o m*/ // retrieve models from model slot List<DslApplication> applications = Lists.newArrayList(); for (DslApplication application : Iterables.filter(slotContent, DslApplication.class)) { applications.add(application); } if (applications.isEmpty()) { issues.addError(this, "No DslApplication instance found in model slot", slotContent, null, null); } else { // validate models for (DslApplication application : applications) { LOGGER.debug("Validating application '{}'", application.getName()); Diagnostic diagnostic = Diagnostician.INSTANCE.validate(application); switch (diagnostic.getSeverity()) { case Diagnostic.ERROR: issues.addError(this, diagnostic.getMessage(), diagnostic.getData().get(0), diagnostic.getException(), Collections.emptyList()); break; case Diagnostic.WARNING: issues.addWarning(this, diagnostic.getMessage(), diagnostic.getData().get(0), diagnostic.getException(), null); break; } } } } }
From source file:org.eclipse.emf.eson.scoping.SimpleEPackageScope.java
protected Iterable<IEObjectDescription> getLocalElementsByEClass(final EClass eClass) { Iterable<IEObjectDescription> localElements = getAllLocalElements(); return Iterables.filter(localElements, new Predicate<IEObjectDescription>() { @Override//from ww w . j a va2 s . c o m public boolean apply(IEObjectDescription input) { return input.getEClass().equals(eClass); } }); }
From source file:org.jclouds.gogrid.compute.strategy.GoGridListNodesStrategy.java
@Override public Iterable<? extends NodeMetadata> listDetailsOnNodesMatching(Predicate<ComputeMetadata> filter) { return Iterables.filter( Iterables.transform(client.getServerServices().getServerList(), serverToNodeMetadata), filter); }
From source file:ratpack.file.internal.DefaultFileHttpTransmitter.java
private static ImmutableSet<String> defaultExcludedMimeTypes(MimeTypes mimeTypes) { return ImmutableSet .copyOf(Iterables.concat(Iterables.filter(mimeTypes.getKnownMimeTypes(), new Predicate<String>() { @Override/*from w ww . j av a2 s . c o m*/ public boolean apply(String type) { return (type.startsWith("image/") || type.startsWith("audio/") || type.startsWith("video/")) && !type.endsWith("+xml"); } }), ImmutableSet.of("application/compress", "application/zip", "application/gzip"))); }
From source file:com.yahoo.sql4d.delete.DeleteMeta.java
/** * Retain segments only overlapping with the range. * @param allSegments /*from w ww .jav a2 s . c om*/ */ public void filterSegments(List<Interval> allSegments) { segmentsToDelete = Lists.newArrayList(Iterables.filter(allSegments, new Predicate<Interval>() { @Override public boolean apply(Interval i) { return i.fallsIn(interval); } })); }
From source file:com.netxforge.netxstudio.common.model.ComputationContextProvider.java
/** * Get the {@link DateTimeRange period} setting from the computation * context./*w w w. jav a2 s .c o m*/ * * @return the period or <code>null</code> if none specified. */ public DateTimeRange periodInContext() { final Iterable<IComputationContext> filter = Iterables.filter(context, new Predicate<IComputationContext>() { public boolean apply(IComputationContext o) { return o.getContext() instanceof DateTimeRange; } }); if (Iterables.size(filter) == 1) { return (DateTimeRange) ((IComputationContext) filter.iterator().next()).getContext(); } return null; }
From source file:com.eucalyptus.auth.AuthEvaluationContext.java
@Nullable default Set<TypedPrincipal> getPrincipals(final Predicate<TypedPrincipal> filter) { final Set<TypedPrincipal> principals = getPrincipals(); return principals == null ? null : ImmutableSet.copyOf(Iterables.filter(principals, filter)); }
From source file:org.gradle.performance.results.FilteredResultsStore.java
@Override public List<String> getTestNames() { Iterable<String> filtered = Iterables.filter(delegate.getTestNames(), include ? inclusionPredicate : exclusionPredicate); return Lists.newArrayList(filtered); }