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.xtext.scoping.impl.MultimapBasedSelectable.java
@Override public Iterable<IEObjectDescription> getExportedObjectsByObject(final EObject object) { if (allDescriptions.isEmpty()) return Collections.emptyList(); final URI uri = EcoreUtil2.getPlatformResourceOrNormalizedURI(object); return Iterables.filter(allDescriptions, new Predicate<IEObjectDescription>() { @Override/*from w ww.j a va2 s. co m*/ public boolean apply(IEObjectDescription input) { if (input.getEObjectOrProxy() == object) return true; if (uri.equals(input.getEObjectURI())) { return true; } return false; } }); }
From source file:eu.numberfour.n4js.ts.scoping.ValidatingScope.java
/** * Returns a filtered iterable of descriptions. Only elements that evaluate to * {@code true} when passed to the {@link #allElementsFilter} are returned. *//* w w w .ja v a 2s . c o m*/ @Override public Iterable<IEObjectDescription> getAllElements() { return Iterables.filter(delegate.getAllElements(), allElementsFilter); }
From source file:org.obiba.opal.web.project.permissions.ProjectVariablePermissionsResource.java
/** * Get variable-level permissions of a variable in the project. * * @param domain/* www . ja va2s .c o m*/ * @param type * @return */ @GET public Iterable<Opal.Acl> getTableVariablesPermissions(@QueryParam("type") SubjectType type) { // make sure datasource, table and variable exists MagmaEngine.get().getDatasource(name).getValueTable(table).getVariable(variable); Iterable<SubjectAclService.Permissions> permissions = subjectAclService.getNodePermissions(DOMAIN, getNode(), type); return Iterables.transform( Iterables.filter(permissions, new ProjectPermissionsResource.MagmaPermissionsPredicate()), PermissionsToAclFunction.INSTANCE); }
From source file:org.trancecode.xml.saxon.SaxonAxis.java
public static Iterable<XdmNode> namespaces(final XdmNode node) { return Iterables.filter(axis(node, Axis.NAMESPACE), XdmNode.class); }
From source file:org.linqs.psl.utils.dataloading.graph.Entity.java
public Iterable<Relation<ET, RT>> getAllRelations(final Subgraph<ET, RT> subgraph) { return Iterables.filter(relations.values(), new Predicate<Relation<ET, RT>>() { @Override//w w w.ja va 2s.c o m public boolean apply(Relation<ET, RT> rel) { return subgraph.containsRelation(rel); } }); }
From source file:sg.atom.utils._beta.functional.FunctionalIterable.java
public <RetType> FunctionalIterable<RetType> keep(Function<T, RetType> fn) { return new FunctionalIterable<RetType>( Iterables.filter(Iterables.transform(delegate, fn), Predicates.notNull())); }
From source file:org.eclipse.sirius.diagram.sequence.business.internal.query.ISequenceElementQuery.java
/** * Return the flagged absolute bounds, ie the last known logical bounds. * //from w ww . j av a 2 s. c om * @return the flagged absolute bounds. */ public Rectangle getFlaggedAbsoluteBounds() { Rectangle bounds = new Rectangle(); if (event.getNotationView() != null && event.getNotationView().getElement() instanceof DDiagramElement) { DDiagramElement dde = (DDiagramElement) event.getNotationView().getElement(); Iterable<AbsoluteBoundsFilter> flags = Iterables.filter(dde.getGraphicalFilters(), AbsoluteBoundsFilter.class); if (!Iterables.isEmpty(flags)) { AbsoluteBoundsFilter flag = flags.iterator().next(); bounds.x = safeGetInt(flag.getX()); bounds.y = safeGetInt(flag.getY()); bounds.width = safeGetInt(flag.getWidth()); bounds.height = safeGetInt(flag.getHeight()); } } return bounds; }
From source file:org.eclipse.xtend.core.scoping.LocalResourceFilteringTypeScope.java
@Override public Iterable<IEObjectDescription> getElements(QualifiedName name) { return Iterables.filter(delegate.getElements(name), new Predicate<IEObjectDescription>() { @Override/*from ww w. java2 s. c o m*/ public boolean apply(IEObjectDescription input) { return !isFiltered(input.getQualifiedName()); } }); }
From source file:org.summer.dsl.builder.impl.javasupport.ProjectClasspathChangeListener.java
public void elementChanged(ElementChangedEvent event) { if (workspace != null && workspace.isAutoBuilding()) { try {/* w w w.j a v a2 s .c om*/ if (event.getDelta() != null) { Set<IJavaProject> javaProjects = getJavaProjectsWithClasspathChange(event.getDelta()); if (!javaProjects.isEmpty()) { Set<IProject> projects = Sets.newHashSet(Iterables .filter(Iterables.transform(javaProjects, new Function<IJavaProject, IProject>() { public IProject apply(IJavaProject from) { return from.getProject(); } }), Predicates.notNull())); dirtyStateManager.notifyListeners(new CoarseGrainedChangeEvent()); buildManager.scheduleBuildIfNecessary(projects); } } } catch (WrappedException e) { log.error(e.getCause().getMessage(), e.getCause()); } catch (RuntimeException e) { log.error(e.getMessage(), e); } } }
From source file:org.waveprotocol.box.server.waveserver.LocalWaveletContainerImpl.java
private static Iterable<ParticipantId> participantsRemovedBy(Iterable<WaveletOperation> ops) { return Iterables.transform(Iterables.filter(ops, RemoveParticipant.class), PARTICIPANT_REMOVED_BY); }