List of usage examples for java.util Collections emptyIterator
@SuppressWarnings("unchecked") public static <T> Iterator<T> emptyIterator()
From source file:org.apache.tinkerpop.gremlin.structure.util.star.StarGraph.java
@Override public Iterator<Edge> edges(final Object... edgeIds) { return null == this.starVertex ? Collections.emptyIterator() : Stream.concat(// w w w .j av a2s. co m null == this.starVertex.inEdges ? Stream.empty() : this.starVertex.inEdges.values().stream(), null == this.starVertex.outEdges ? Stream.empty() : this.starVertex.outEdges.values().stream()) .flatMap(List::stream).filter(edge -> { // todo: kinda fishy - need to better nail down how stuff should work here - none of these feel consistent right now. if (edgeIds.length > 0 && edgeIds[0] instanceof Edge) return ElementHelper.idExists(edge.id(), Stream.of(edgeIds).map(e -> ((Edge) e).id()).toArray()); else return ElementHelper.idExists(edge.id(), edgeIds); }).iterator(); }
From source file:org.apache.wicket.MarkupContainer.java
/** * Gives an iterator that allow you to iterate through the children of this markup container in * the order the children were added. The iterator supports additions and removals from the list * of children during iteration.//from ww w . ja v a 2s .c om * * @return Iterator that iterates through children in the order they were added */ @Override public Iterator<Component> iterator() { /** * Iterator that knows how to change between a single child, list of children and map of * children. Keeps track when the iterator was last sync'd with the markup container's * tracking of changes to the list of children. */ class MarkupChildIterator implements Iterator<Component> { private int indexInRemovalsSinceLastUpdate = removals_size(); private int expectedModCounter = -1; private Component currentComponent = null; private Iterator<Component> internalIterator = null; @Override public boolean hasNext() { refreshInternalIteratorIfNeeded(); return internalIterator.hasNext(); } @Override public Component next() { refreshInternalIteratorIfNeeded(); return currentComponent = internalIterator.next(); } @Override public void remove() { MarkupContainer.this.remove(currentComponent); refreshInternalIteratorIfNeeded(); } private void refreshInternalIteratorIfNeeded() { if (modCounter != 0 && expectedModCounter >= modCounter) return; if (children == null) { internalIterator = Collections.emptyIterator(); } else if (children instanceof Component) { internalIterator = Collections.singleton((Component) children).iterator(); } else if (children instanceof List) { List<Component> childrenList = children(); internalIterator = childrenList.iterator(); } else { Map<String, Component> childrenMap = children(); internalIterator = childrenMap.values().iterator(); } // since we now have a new iterator, we need to set it to the last known position currentComponent = findLastExistingChildAlreadyReturned(currentComponent); expectedModCounter = modCounter; indexInRemovalsSinceLastUpdate = removals_size(); if (currentComponent != null) { // move the new internal iterator to the place of the last processed component while (internalIterator.hasNext() && internalIterator.next() != currentComponent) // noop ; } } private Component findLastExistingChildAlreadyReturned(Component target) { while (true) { if (target == null) return null; RemovedChild removedChild = null; for (int i = indexInRemovalsSinceLastUpdate; i < removals_size(); i++) { RemovedChild curRemovedChild = removals_get(i); if (curRemovedChild.removedChild == target || curRemovedChild.removedChild == null) { removedChild = curRemovedChild; break; } } if (removedChild == null) { return target; } else { target = removedChild.previousSibling; } } } } ; return new MarkupChildIterator(); }
From source file:org.bimserver.plugins.MavenPluginLocation.java
public Iterator<MavenPluginVersion> iterateAllVersions() { Artifact artifact = new DefaultArtifact(groupId, artifactId, null, "[0,)"); VersionRangeRequest rangeRequest = new VersionRangeRequest(); rangeRequest.setArtifact(artifact);/*w w w. j a v a 2 s . c o m*/ rangeRequest.setRepositories(mavenPluginRepository.getRepositoriesAsList()); try { VersionRangeResult rangeResult = mavenPluginRepository.getSystem() .resolveVersionRange(mavenPluginRepository.getSession(), rangeRequest); List<Version> versions = rangeResult.getVersions(); if (!versions.isEmpty()) { Iterator<Version> versionIterator = Lists.reverse(versions).iterator(); return Iterators.transform(versionIterator, new Function<Version, MavenPluginVersion>() { @Override public MavenPluginVersion apply(Version version) { try { MavenPluginVersion mavenPluginVersion = createMavenVersion(version); return mavenPluginVersion; } catch (ArtifactDescriptorException | ArtifactResolutionException | IOException | XmlPullParserException e) { LOGGER.error("", e); } return null; } }); } } catch (VersionRangeResolutionException e) { LOGGER.error("", e); } return Collections.emptyIterator(); }
From source file:org.geoserver.qos.web.OperationAnomalyFeedPanel.java
public OperationAnomalyFeedPanel(String id, IModel<ReferenceType> model) { super(id, model); anomalyFeedModel = model;/*www . j a va2 s. co m*/ ReferenceType anomalyFeed = model.getObject(); if (anomalyFeed.getAbstracts() == null) { anomalyFeed.setAbstracts( new ArrayList<OwsAbstract>(Arrays.asList(new OwsAbstract[] { new OwsAbstract("") }))); } final WebMarkupContainer div = new WebMarkupContainer("anomalyDiv"); div.setOutputMarkupId(true); add(div); TextField<String> hrefField = new TextField<String>("href", new PropertyModel<>(anomalyFeedModel, "href")) { }; div.add(hrefField); TextField<String> abstractField = new TextField<String>("abstract", new PropertyModel<>(anomalyFeedModel, "abstractOne")) { }; div.add(abstractField); final AutoCompleteTextField<String> formatField = new AutoCompleteTextField<String>("format", new PropertyModel<>(anomalyFeedModel, "format")) { @Override protected Iterator<String> getChoices(String input) { if (StringUtils.isEmpty(input) || StringUtils.isEmpty(input.trim())) { return Collections.emptyIterator(); } return MimeTypes.getMimeTypeValuesStream().filter(m -> m.startsWith(input)).limit(10).iterator(); } }; // TextField<String> formatField = // new TextField<String>("format", new PropertyModel<>(anomalyFeed, // "format")) {}; div.add(formatField); final AjaxSubmitLink deleteLink = new AjaxSubmitLink("deleteLink") { @Override public void onAfterSubmit(AjaxRequestTarget target, Form<?> form) { delete(target); } }; div.add(deleteLink); }
From source file:org.janusgraph.graphdb.tinkerpop.JanusGraphBlueprintsTransaction.java
@Override public Iterator<Vertex> vertices(Object... vids) { if (vids == null || vids.length == 0) return (Iterator) getVertices().iterator(); ElementUtils.verifyArgsMustBeEitherIdorElement(vids); long[] ids = new long[vids.length]; int pos = 0;/*from w w w.ja va 2 s.co m*/ for (int i = 0; i < vids.length; i++) { long id = ElementUtils.getVertexId(vids[i]); if (id > 0) ids[pos++] = id; } if (pos == 0) return Collections.emptyIterator(); if (pos < ids.length) ids = Arrays.copyOf(ids, pos); return (Iterator) getVertices(ids).iterator(); }
From source file:org.janusgraph.graphdb.tinkerpop.JanusGraphBlueprintsTransaction.java
@Override public Iterator<Edge> edges(Object... eids) { if (eids == null || eids.length == 0) return (Iterator) getEdges().iterator(); ElementUtils.verifyArgsMustBeEitherIdorElement(eids); RelationIdentifier[] ids = new RelationIdentifier[eids.length]; int pos = 0;/*from w ww . j av a2 s.c o m*/ for (int i = 0; i < eids.length; i++) { RelationIdentifier id = ElementUtils.getEdgeId(eids[i]); if (id != null) ids[pos++] = id; } if (pos == 0) return Collections.emptyIterator(); if (pos < ids.length) ids = Arrays.copyOf(ids, pos); return (Iterator) getEdges(ids).iterator(); }
From source file:org.jboss.forge.addon.configuration.ConfigurationAdapterSubset.java
@Override public Iterator<String> getKeys() { synchronized (parent) { try {/*from w w w. j a v a 2 s .co m*/ return parent.subset(prefix).getKeys(); } catch (IllegalArgumentException e) { return Collections.emptyIterator(); } } }
From source file:org.phenotips.data.permissions.internal.DefaultPermissionsManager.java
@Override public Iterator<Patient> filterByVisibility(Iterator<Patient> patients, Visibility requiredVisibility) { if (requiredVisibility == null) { return patients; }//from ww w . ja va2 s . com if (patients == null || !patients.hasNext()) { return Collections.emptyIterator(); } return new FilteringIterator(patients, requiredVisibility, this); }
From source file:org.phenotips.entities.internal.AbstractPrimaryEntityManager.java
@Override public Iterator<E> getAll() { try {/*from w w w . ja v a 2s .c om*/ Query q = this.qm .createQuery("select doc.fullName from Document as doc, doc.object(" + this.localSerializer.serialize(getEntityXClassReference()) + ") as entity where doc.name not in (:template1, :template2) order by doc.name asc", Query.XWQL) .bindValue("template1", this.getEntityXClassReference().getName() + "Template") .bindValue("template2", StringUtils.removeEnd(this.getEntityXClassReference().getName(), "Class") + "Template"); List<String> docNames = q.execute(); return new LazyPrimaryEntityIterator<>(docNames, this); } catch (QueryException ex) { this.logger.warn("Failed to query all entities of type [{}]: {}", getEntityXClassReference(), ex.getMessage()); } return Collections.emptyIterator(); }
From source file:org.roda.core.common.iterables.CloseableIterables.java
public static <T> CloseableIterable<T> empty() { return new CloseableIterable<T>() { @Override//ww w. j a v a 2 s. co m public void close() throws IOException { // nothing to do } @Override public Iterator<T> iterator() { return Collections.emptyIterator(); } }; }