List of usage examples for com.google.common.collect Iterators emptyIterator
@Deprecated public static <T> UnmodifiableIterator<T> emptyIterator()
From source file:org.eclipse.ocl.pivot.internal.complete.PartialProperties.java
@Override @SuppressWarnings("null") public @NonNull Iterator<Property> iterator() { if (!isResolved) { resolve();/*from w w w . j a v a 2 s . c o m*/ } if (resolution != null) { return Iterators.singletonIterator(resolution); } else if (partials != null) { return partials.iterator(); } else { return Iterators.emptyIterator(); } }
From source file:presto.android.gui.graph.NNode.java
public Iterator<NNode> getTextNodes() { if (textNodes == null) { return Iterators.emptyIterator(); } return textNodes.iterator(); }
From source file:org.geogit.osm.out.cli.OSMExport.java
private Iterator<EntityContainer> getFeatures(String ref) { Optional<ObjectId> id = geogit.command(RevParse.class).setRefSpec(ref).call(); if (!id.isPresent()) { return Iterators.emptyIterator(); }/*from w w w . j a v a2 s . c o m*/ LsTreeOp op = geogit.command(LsTreeOp.class).setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES) .setReference(ref); if (bbox != null) { final Envelope env; try { env = new Envelope(Double.parseDouble(bbox.get(0)), Double.parseDouble(bbox.get(2)), Double.parseDouble(bbox.get(1)), Double.parseDouble(bbox.get(3))); } catch (NumberFormatException e) { throw new IllegalArgumentException("Wrong bbox definition"); } Predicate<Bounded> filter = new Predicate<Bounded>() { @Override public boolean apply(final Bounded bounded) { boolean intersects = bounded.intersects(env); return intersects; } }; op.setBoundsFilter(filter); } Iterator<NodeRef> iterator = op.call(); final EntityConverter converter = new EntityConverter(); Function<NodeRef, EntityContainer> function = new Function<NodeRef, EntityContainer>() { @Override @Nullable public EntityContainer apply(@Nullable NodeRef ref) { RevFeature revFeature = geogit.command(RevObjectParse.class).setObjectId(ref.objectId()) .call(RevFeature.class).get(); SimpleFeatureType featureType; if (ref.path().startsWith(OSMUtils.NODE_TYPE_NAME)) { featureType = OSMUtils.nodeType(); } else { featureType = OSMUtils.wayType(); } SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType); RevFeatureType revFeatureType = RevFeatureType.build(featureType); List<PropertyDescriptor> descriptors = revFeatureType.sortedDescriptors(); ImmutableList<Optional<Object>> values = revFeature.getValues(); for (int i = 0; i < descriptors.size(); i++) { PropertyDescriptor descriptor = descriptors.get(i); Optional<Object> value = values.get(i); featureBuilder.set(descriptor.getName(), value.orNull()); } SimpleFeature feature = featureBuilder.buildFeature(ref.name()); Entity entity = converter.toEntity(feature); EntityContainer container; if (entity instanceof Node) { container = new NodeContainer((Node) entity); } else { container = new WayContainer((Way) entity); } return container; } }; return Iterators.transform(iterator, function); }
From source file:com.android.tools.idea.gradle.compiler.PostProjectBuildTasksExecutor.java
public void onBuildCompletion(@NotNull CompileContext context) { Iterator<String> errors = Iterators.emptyIterator(); CompilerMessage[] errorMessages = context.getMessages(CompilerMessageCategory.ERROR); if (errorMessages.length > 0) { errors = new CompilerMessageIterator(errorMessages); }// w w w .j a v a2 s . c o m //noinspection TestOnlyProblems onBuildCompletion(errors, errorMessages.length); }
From source file:org.eclipse.mylyn.wikitext.core.util.XmlStreamWriterAdapter.java
@Override public NamespaceContext getNamespaceContext() { return new NamespaceContext() { @Override/* ww w. jav a 2s. co m*/ public Iterator<String> getPrefixes(String namespaceUri) { String prefix = getPrefix(namespaceUri); if (prefix == null) { return Iterators.emptyIterator(); } return Collections.singletonList(prefix).iterator(); } @Override public String getPrefix(String namespaceUri) { return delegate.getPrefix(namespaceUri); } @Override public String getNamespaceURI(String prefix) { return delegate.getNamespaceURI(prefix); } }; }
From source file:com.github.fge.jsonschema.report.AbstractProcessingReport.java
@Override public Iterator<ProcessingMessage> iterator() { return Iterators.emptyIterator(); }
From source file:org.apache.jackrabbit.oak.security.principal.PrincipalProviderImpl.java
@Nonnull @Override// ww w. ja v a 2 s . c o m public Iterator<? extends Principal> findPrincipals(@Nullable final String nameHint, final int searchType) { try { Iterator<Authorizable> authorizables = findAuthorizables(nameHint, searchType); Iterator<Principal> principals = Iterators.transform( Iterators.filter(authorizables, Predicates.notNull()), new AuthorizableToPrincipal()); if (matchesEveryone(nameHint, searchType)) { principals = Iterators.concat(principals, Iterators.singletonIterator(EveryonePrincipal.getInstance())); return Iterators.filter(principals, new EveryonePredicate()); } else { return principals; } } catch (RepositoryException e) { log.debug(e.getMessage()); return Iterators.emptyIterator(); } }
From source file:org.gradle.api.internal.DefaultDomainObjectCollection.java
Iterator<T> iteratorNoFlush() { if (store.constantTimeIsEmpty()) { return Iterators.emptyIterator(); }//from w ww . j a va 2 s .co m return new IteratorImpl(store.iteratorNoFlush()); }
From source file:org.janusgraph.graphdb.types.system.EmptyVertex.java
@Override public <V> Iterator<VertexProperty<V>> properties(String... propertyKeys) { return Iterators.emptyIterator(); }
From source file:co.cask.hydrator.plugin.realtime.Kafka08SimpleApiConsumer.java
@Override protected Iterator<KafkaMessage<Long>> readMessages(KafkaConsumerInfo<Long> consumerInfo) throws Exception { final TopicPartition topicPartition = consumerInfo.getTopicPartition(); String topic = topicPartition.getTopic(); int partition = topicPartition.getPartition(); // Fetch message from Kafka. final SimpleConsumer consumer = getConsumer(consumerInfo); if (consumer == null) { return Iterators.emptyIterator(); }/*from w ww .ja v a 2s. co m*/ long readOffset = consumerInfo.getReadOffset(); if (readOffset < 0) { readOffset = getReadOffset(consumer, topic, partition, readOffset); consumerInfo.setReadOffset(readOffset); } FetchRequest fetchRequest = new FetchRequestBuilder().clientId(consumer.clientId()) .addFetch(topic, partition, readOffset, consumerInfo.getFetchSize()).build(); FetchResponse response = consumer.fetch(fetchRequest); // Fetch failed if (response.hasError()) { handleFetchError(consumerInfo, consumer, readOffset, response.errorCode(topic, partition)); return Iterators.emptyIterator(); } // Returns an Iterator of message final long fetchReadOffset = readOffset; final Iterator<MessageAndOffset> messages = response.messageSet(topic, partition).iterator(); return new AbstractIterator<KafkaMessage<Long>>() { @Override protected KafkaMessage<Long> computeNext() { while (messages.hasNext()) { MessageAndOffset messageAndOffset = messages.next(); if (messageAndOffset.offset() < fetchReadOffset) { // Older message read (which is valid in Kafka), skip it. continue; } // Lets get the Kafka message based on last offset Message message = messageAndOffset.message(); return new KafkaMessage<>(topicPartition, messageAndOffset.nextOffset(), message.key(), message.payload()); } return endOfData(); } }; }