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.grouplens.lenskit.collections.RemovableLongSortedArraySet.java
@Override public boolean removeAll(Collection<?> c) { if (c instanceof LongCollection) { return removeAll((LongCollection) c); } else {/*from w w w. j av a 2 s .co m*/ long[] longs = LongIterators .unwrap(LongIterators.asLongIterator(Iterators.filter(c.iterator(), Long.class))); Arrays.sort(longs); return removeAll(LongArrayList.wrap(longs).iterator()); } }
From source file:org.apache.druid.timeline.partition.PartitionHolder.java
public PartitionChunk<T> getChunk(final int partitionNum) { final Iterator<PartitionChunk<T>> retVal = Iterators.filter(holderSet.iterator(), input -> input.getChunkNumber() == partitionNum); return retVal.hasNext() ? retVal.next() : null; }
From source file:nz.ac.massey.cs.guery.adapters.blueprints.BlueprintsAdapter.java
@Override public Iterator<Edge> getOutEdges(Vertex vertex, Predicate<? super Edge> filter) { return Iterators.filter(this.getOutEdges(vertex), filter); }
From source file:org.fcrepo.kernel.impl.rdf.impl.LdpContainerRdfContext.java
/** * Default constructor./*from w w w .j a v a 2 s. c o m*/ * * @param resource the resource * @param idTranslator the id translator * @throws javax.jcr.RepositoryException if repository exception occurred */ public LdpContainerRdfContext(final FedoraResource resource, final IdentifierConverter<Resource, FedoraResource> idTranslator) throws RepositoryException { super(resource, idTranslator); final Iterator<Property> memberReferences = resource.getNode().getReferences(LDP_MEMBER_RESOURCE); final Iterator<Property> properties = Iterators.filter(memberReferences, isContainer); if (properties.hasNext()) { LOGGER.trace("Found membership containers for {}", resource); concat(membershipContext(properties)); } }
From source file:org.jnario.jnario.test.util.ModelStore.java
public Iterator<EObject> iterator() { return Iterators.filter(resourceSet.getAllContents(), EObject.class); }
From source file:org.eclipse.incquery.patternlanguage.emf.scoping.BaseMetamodelProviderService.java
@Override public boolean isGeneratedCodeAvailable(EPackage ePackage, ResourceSet set) { if (getProvidedMetamodels().contains(ePackage.getNsURI())) { Iterator<EClassifier> it = Iterators.filter(ePackage.eAllContents(), EClassifier.class); boolean missingNameFound = false; while (!missingNameFound && it.hasNext()) { final String instanceClassName = it.next().getInstanceClassName(); missingNameFound = Strings.isNullOrEmpty(instanceClassName); }//from w w w .j a v a 2 s .c o m return !missingNameFound || getGenmodelRegistry().findGenPackage(ePackage.getNsURI(), set) != null; } else { return false; } }
From source file:org.akubraproject.map.IdMappingBlobStoreConnection.java
@Override public Iterator<URI> listBlobIds(final String filterPrefix) throws IOException { // list the appropriate internal ids String intPrefix = null;/*w w w . j a v a2s. c om*/ Iterator<URI> intIterator; if (filterPrefix == null) { intIterator = delegate.listBlobIds(null); } else { intPrefix = mapper.getInternalPrefix(filterPrefix); intIterator = delegate.listBlobIds(intPrefix); } // transform internal ids to external form on the way out Iterator<URI> extIterator = Iterators.transform(intIterator, new Function<URI, URI>() { public URI apply(URI uri) { return mapper.getExternalId(uri); } }); if (filterPrefix != null && intPrefix == null) { // also need to post-filter return Iterators.filter(extIterator, new Predicate<URI>() { public boolean apply(URI uri) { return uri.toString().startsWith(filterPrefix); } }); } else { // no need to filter return extIterator; } }
From source file:com.metamx.druid.partition.PartitionHolder.java
public PartitionChunk<T> getChunk(final int partitionNum) { final Iterator<PartitionChunk<T>> retVal = Iterators.filter(holderSet.iterator(), new Predicate<PartitionChunk<T>>() { @Override// ww w . jav a 2s . c o m public boolean apply(PartitionChunk<T> input) { return input.getChunkNumber() == partitionNum; } }); return retVal.hasNext() ? retVal.next() : null; }
From source file:org.fcrepo.kernel.modeshape.rdf.impl.LdpContainerRdfContext.java
/** * Default constructor./*from w w w . j a va2s.c o m*/ * * @param resource the resource * @param idTranslator the id translator * @throws javax.jcr.RepositoryException if repository exception occurred */ public LdpContainerRdfContext(final FedoraResource resource, final IdentifierConverter<Resource, FedoraResource> idTranslator) throws RepositoryException { super(resource, idTranslator); @SuppressWarnings("unchecked") final Iterator<Property> memberReferences = resource.getNode().getReferences(LDP_MEMBER_RESOURCE); final Iterator<Property> properties = Iterators.filter(memberReferences, UncheckedPredicate.uncheck((final Property p) -> { final Node container = p.getParent(); return container.isNodeType(LDP_DIRECT_CONTAINER) || container.isNodeType(LDP_INDIRECT_CONTAINER); })::test); if (properties.hasNext()) { LOGGER.trace("Found membership containers for {}", resource); concat(membershipContext(properties)); } }
From source file:org.eclipse.sirius.ecore.extender.tool.internal.ReferencesResolver.java
private void resolveCrossReferences(EObject eObject) { Iterator<EReference> it = Iterators.filter(eObject.eClass().getEAllReferences().iterator(), filter); while (it.hasNext()) { eObject.eGet(it.next());/*from w w w . ja v a 2s.c o m*/ } }