List of usage examples for com.google.common.collect Iterators filter
@SuppressWarnings("unchecked") @GwtIncompatible("Class.isInstance") @CheckReturnValue public static <T> UnmodifiableIterator<T> filter(Iterator<?> unfiltered, Class<T> desiredType)
From source file:org.mandarax.rt._InDomainRelInstances.java
public static ResourceIterator<_InDomainRel> contains(final DerivationController _derivation, final Iterable container, final Object element) { final int _derivationlevel = _derivation.size(); final Iterator iterator = Iterators.filter(container.iterator(), new Predicate() { @Override//w ww. j a v a 2 s. c om public boolean apply(Object e) { return element.equals(e); } }); ResourceIterator<_InDomainRel> r = new ResourceIterator<_InDomainRel>() { int count = 0; @Override public boolean hasNext() { return iterator.hasNext(); } @Override public _InDomainRel next() { _derivation.pop(_derivationlevel); _derivation.log("In.genfact" + (count++), DerivationController.INDOMAIN, new Properties()); _InDomainRel rel = new _InDomainRel(); rel.container = container; rel.element = iterator.next(); return rel; } @Override public void remove() { iterator.remove(); } @Override public void close() { if (iterator instanceof Closeable) { try { ((Closeable) iterator).close(); } catch (IOException x) { errorOnClose(container); } } } }; return r; }
From source file:org.calrissian.mango.collect.CloseableIterators.java
/** * Returns the elements of {@code unfiltered} that satisfy a predicate. *//*w w w . jav a 2 s .co m*/ public static <T> CloseableIterator<T> filter(final CloseableIterator<T> iterator, final Predicate<T> filter) { return wrap(Iterators.filter(iterator, filter), iterator); }
From source file:nz.ac.massey.cs.guery.impl.BreadthFirstPathFinder.java
public Iterator<Path<V, E>> findLinks(GraphAdapter<V, E> g, V start, final int minLength, int maxLength, boolean outgoing, Predicate<E> filter, boolean computeAll) { if (maxLength == 1) { return findDirectLinks(g, start, minLength, outgoing, filter, computeAll); }//from w w w .j a v a2s. c o m Iterator<Path<V, E>> iter = new BreadthFirstPathIterator<V, E>(g, start, minLength, maxLength, outgoing, filter, computeAll); if (minLength > 1) { return Iterators.filter(iter, new Predicate<Path<V, E>>() { @Override public boolean apply(Path<V, E> p) { return p.size() >= minLength; } }); } else { return iter; } }
From source file:org.locationtech.geogig.api.porcelain.CleanOp.java
/** * @see java.util.concurrent.Callable#call() *///from ww w .jav a2 s .c om protected WorkingTree _call() { if (path != null) { // check that is a valid path NodeRef.checkValidPath(path); Optional<NodeRef> ref = command(FindTreeChild.class).setParent(workingTree().getTree()) .setChildPath(path).call(); Preconditions.checkArgument(ref.isPresent(), "pathspec '%s' did not match any tree", path); Preconditions.checkArgument(ref.get().getType() == TYPE.TREE, "pathspec '%s' did not resolve to a tree", path); } final Iterator<DiffEntry> unstaged = command(DiffWorkTree.class).setFilter(path).call(); final Iterator<DiffEntry> added = Iterators.filter(unstaged, new Predicate<DiffEntry>() { @Override public boolean apply(@Nullable DiffEntry input) { return input.changeType().equals(ChangeType.ADDED); } }); Iterator<String> addedPaths = Iterators.transform(added, new Function<DiffEntry, String>() { @Override public String apply(DiffEntry input) { return input.newPath(); } }); workingTree().delete(addedPaths); return workingTree(); }
From source file:com.dangdang.ddframe.rdb.sharding.parser.visitor.or.node.AbstractOrASTNode.java
/** * ????.//w ww . j a v a 2 s . c o m * * @return ??? */ public final List<ConditionContext> getCondition() { return Lists.newArrayList(Iterators .filter(Lists.transform(nestedConditions, new Function<List<Condition>, ConditionContext>() { @Override public ConditionContext apply(final List<Condition> input) { ConditionContext result = new ConditionContext(); for (Condition each : input) { result.add(each); } return result; } }).iterator(), new Predicate<ConditionContext>() { @Override public boolean apply(final ConditionContext input) { return !input.isEmpty(); } })); }
From source file:org.eclipse.sirius.diagram.ui.business.internal.migration.DiagramRepresentationsFileMigrationParticipantV680.java
/** * Removes layout constraints from compartments. * // w w w.j ava2 s .c om * @param diagrams * list of GMF Diagram to migrate. */ public void migrateCompartmentsWithLayoutConstraints(List<Diagram> diagrams) { for (Diagram diagram : diagrams) { Iterator<EObject> compartmentIterator = Iterators.filter(diagram.eAllContents(), new IsCompartmentPredicate()); while (compartmentIterator.hasNext()) { Node node = (Node) compartmentIterator.next(); if (node.getLayoutConstraint() != null) { node.setLayoutConstraint(null); } } } }
From source file:org.akubraproject.mem.MemConnection.java
@Override public Iterator<URI> listBlobIds(final String filterPrefix) { ensureOpen();/* w w w .j a va 2 s .c o m*/ synchronized (blobs) { return Iterators.filter(new ArrayList<URI>(blobs.keySet()).iterator(), new Predicate<URI>() { public boolean apply(URI uri) { return ((filterPrefix == null) || uri.toString().startsWith(filterPrefix)); } }); } }
From source file:co.cask.cdap.gateway.discovery.VersionFilteredServiceDiscovered.java
@Override public Iterator<Discoverable> iterator() { if (version == null) { return delegate.iterator(); }/* ww w .j a v a 2 s .c om*/ return Iterators.filter(delegate.iterator(), predicate); }
From source file:org.eclipse.sirius.diagram.ui.business.internal.browser.DiagramEditorBrowser.java
private Iterator<IGraphicalEditPart> filterMatchingEditParts(final Predicate<IGraphicalEditPart> predicate, final Iterator<IGraphicalEditPart> parts) { final Iterator<IGraphicalEditPart> mines = Iterators.filter(parts, new Predicate<IGraphicalEditPart>() { public boolean apply(final IGraphicalEditPart input) { return predicate.apply(input); }/* w w w. j a v a 2 s . c o m*/ }); return mines; }
From source file:ch.ethz.inf.vs.hypermedia.client.utils.Crawler.java
protected UnmodifiableIterator<B> getFilteredIterator(Set<Object> visited, Iterator<B> iter) { return Iterators.filter(iter, (x) -> removeDuplicates(x, visited)); }