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.locationtech.geogig.remotes.pack.UpdateRemoteRefOp.java
/** * Applies result of {@link SendPackOp} (a list of ref diffs in the remote's local * {@code refs/heads/<branch>} namespace and returns the list translated to the local * repository's remotes namespace (i.e. {@code refs/remotes/<remote>/<branch>} *///from ww w . j a v a 2s .c o m @Override protected List<RefDiff> _call() { checkArgument(remote != null, "remote not provided"); final List<RefDiff> remoteLocalRefs = this.refUpdates; final List<RefDiff> localRemoteRefs = convertToRemote(remoteLocalRefs); // update symrefs after refs so their target are present updateRefs(Iterables.filter(localRemoteRefs, (r) -> !isSymRef(r))); updateRefs(Iterables.filter(localRemoteRefs, (r) -> isSymRef(r))); return localRemoteRefs; }
From source file:demo.project.ExportTable.java
@Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try (PrintWriter w = new PrintWriter(file, "utf-8")) { ColumnRanker ranker = table.getDefaultRanker(); write(w, ranker);//from w w w. j a va2 s .c om for (OrderColumn c : Iterables.filter(table.getColumns(), OrderColumn.class)) { w.println(); write(w, c.getRanker()); } } catch (FileNotFoundException | UnsupportedEncodingException e) { Logger.create(ExportTable.class).error("can't write table: " + file, e); } }
From source file:org.jnario.jnario.test.util.FeatureExecutor.java
protected Result runExamples(EObject object) throws MalformedURLException, ClassNotFoundException { CompositeResult result = new CompositeResult(); FeatureFile jnarioFile = (FeatureFile) object; for (Feature feature : Iterables.filter(jnarioFile.getXtendTypes(), Feature.class)) { String jnarioClassName = nameProvider.toJavaClassName(feature); String packageName = jnarioFile.getPackage(); result.add(runTestsInClass(jnarioClassName, packageName)); }/*from ww w . j a v a2 s .co m*/ return result; }
From source file:org.netbeans.modules.android.grammars.UIClassDescriptors.java
private static Iterable<UIClassDescriptor> findByName(Iterable<UIClassDescriptor> classes, Predicate<UIClassDescriptor> predicate) { return Iterables.filter(classes, predicate); }
From source file:org.sonar.core.issue.tracking.Tracking.java
/** * Returns an Iterable to be traversed when matching issues. That means * that the traversal does not fail if method {@link #match(Trackable, Trackable)} * is called.//from www . ja v a2 s . c o m */ public Iterable<RAW> getUnmatchedRaws() { return Iterables.filter(raws, unmatchedRawPredicate); }
From source file:org.eclipse.sirius.diagram.ui.edit.internal.part.DCompartmentConnectionRefreshMgr.java
/** * {@inheritDoc}/*from w w w . j ava2 s.c o m*/ */ @Override protected Set getConnectionNodes(ShapeCompartmentEditPart scep) { Set<?> connectionsNodes = super.getConnectionNodes(scep); if (connectionsNodes != null) { Iterable<?> filteredConnectionNodes = Iterables.filter(connectionsNodes, safeConnection); return Sets.newHashSet(filteredConnectionNodes); } return connectionsNodes; }
From source file:gg.uhc.uhc.modules.team.NoTeamCommand.java
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Iterable<? extends Player> noTeam = Iterables.filter(Bukkit.getOnlinePlayers(), Predicates.not(HAS_TEAM)); String noTeamNames = Joiner.on(", ").join(Iterables.transform(noTeam, FunctionalUtil.PLAYER_NAME_FETCHER)); if (noTeamNames.length() == 0) noTeamNames = messages.getRaw("none"); sender.sendMessage(messages.evalTemplate("list", ImmutableMap.of("players", noTeamNames))); return true;// w w w . j a va2s . c om }
From source file:org.eclipse.sirius.table.business.internal.metamodel.spec.DTableSpec.java
/** * {@inheritDoc}/*from ww w .j av a 2 s . co m*/ */ @Override public void deactivate() { for (DTableElementUpdater updater : Iterables.filter(AllContents.of(this), DTableElementUpdater.class)) { updater.deactivate(); } }
From source file:org.polarsys.reqcycle.traceability.cache.storagebased.engine.pickers.GetTraceabilityPicker.java
private Iterable<Pair<Link, Reachable>> getTraceability(Reachable source, DIRECTION direction) { Iterable<Pair<Link, Reachable>> result = storage.getTraceability(source, direction); return Iterables.filter(result, predicate); }
From source file:org.richfaces.tests.metamer.ftest.extension.finder.SimpleMethodFinder.java
private List<Method> getAndFilterMethods() { for (Class<?> klass : classes) { foundMethods.addAll(Lists.newArrayList(klass.getDeclaredMethods())); }/*from w w w. j a v a2 s. c o m*/ Iterable<Method> result = foundMethods; for (Predicate<Method> filter : filters) { result = Iterables.filter(result, filter); } return Lists.newArrayList(result); }