Java Code Examples for com.google.common.collect.UnmodifiableIterator#hasNext()
The following examples show how to use
com.google.common.collect.UnmodifiableIterator#hasNext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelCollationImpl.java From Bats with Apache License 2.0 | 6 votes |
public int compareTo(RelMultipleTrait o) { final RelCollationImpl that = (RelCollationImpl) o; final UnmodifiableIterator<RelFieldCollation> iterator = that.fieldCollations.iterator(); for (RelFieldCollation f : fieldCollations) { if (!iterator.hasNext()) { return 1; } final RelFieldCollation f2 = iterator.next(); int c = Utilities.compare(f.getFieldIndex(), f2.getFieldIndex()); if (c != 0) { return c; } } return iterator.hasNext() ? -1 : 0; }
Example 2
Source File: RelCollationImpl.java From Quicksql with MIT License | 6 votes |
public int compareTo(@Nonnull RelMultipleTrait o) { final RelCollationImpl that = (RelCollationImpl) o; final UnmodifiableIterator<RelFieldCollation> iterator = that.fieldCollations.iterator(); for (RelFieldCollation f : fieldCollations) { if (!iterator.hasNext()) { return 1; } final RelFieldCollation f2 = iterator.next(); int c = Utilities.compare(f.getFieldIndex(), f2.getFieldIndex()); if (c != 0) { return c; } } return iterator.hasNext() ? -1 : 0; }
Example 3
Source File: AbstractEventQueryImpl.java From neoscada with Eclipse Public License 1.0 | 6 votes |
@Override public synchronized void addListener ( final EventListener eventListener ) { this.listeners.add ( eventListener ); final UnmodifiableIterator<List<Event>> it = Iterators.partition ( AbstractEventQueryImpl.this.events.iterator (), chunkSize ); while ( it.hasNext () ) { final List<org.eclipse.scada.ae.Event> chunk = it.next (); this.executor.execute ( new Runnable () { @Override public void run () { eventListener.handleEvent ( chunk ); } } ); } }
Example 4
Source File: BlockGenericPipe.java From Logistics-Pipes-2 with MIT License | 6 votes |
@Override public Optional<TRSRTransformation> apply(Optional<? extends IModelPart> part) { if(part.isPresent()) { // This whole thing is subject to change, but should do for now. UnmodifiableIterator<String> parts = Models.getParts(part.get()); if(parts.hasNext()) { String name = parts.next(); // only interested in the root level if(!parts.hasNext() && hidden.contains(name)) { return value; } } } return Optional.absent(); }
Example 5
Source File: RelCollationImpl.java From calcite with Apache License 2.0 | 6 votes |
public int compareTo(@Nonnull RelMultipleTrait o) { final RelCollationImpl that = (RelCollationImpl) o; final UnmodifiableIterator<RelFieldCollation> iterator = that.fieldCollations.iterator(); for (RelFieldCollation f : fieldCollations) { if (!iterator.hasNext()) { return 1; } final RelFieldCollation f2 = iterator.next(); int c = Utilities.compare(f.getFieldIndex(), f2.getFieldIndex()); if (c != 0) { return c; } } return iterator.hasNext() ? -1 : 0; }
Example 6
Source File: TestTopicTreeImplEdgeCases.java From hivemq-community-edition with Apache License 2.0 | 5 votes |
@Test public void test_add_same_topic_twice_different_qos_more_than_32_subscribers() throws Exception { topicTree.addTopic("client1", new Topic("a/b", QoS.EXACTLY_ONCE), (byte) 0, null); for (int i = 0; i < 32; i++) { topicTree.addTopic("client" + (i + 2), new Topic("a/b", QoS.EXACTLY_ONCE), (byte) 0, null); } topicTree.addTopic("client1", new Topic("a/b", QoS.AT_LEAST_ONCE), (byte) 0, null); final ImmutableSet<SubscriberWithIdentifiers> subscribers = topicTree.getSubscribers("a/b"); assertEquals(33, subscribers.size()); assertEquals(33, topicTree.subscriptionCounter.getCount()); final UnmodifiableIterator<SubscriberWithIdentifiers> subscribersIterator = subscribers.iterator(); boolean found = false; while (subscribersIterator.hasNext()) { final SubscriberWithIdentifiers next = subscribersIterator.next(); if (next.getSubscriber().equals("client1")) { found = true; assertEquals(1, next.getQos()); } } assertTrue(found); }
Example 7
Source File: DocSchemaInfo.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Collection<String> tableNames() { // TODO: once we support closing/opening tables change this to concreteIndices() // and add state info to the TableInfo. Set<String> tables = new HashSet<>(); tables.addAll(Collections2.filter(Collections2.transform( Arrays.asList(clusterService.state().metaData().concreteAllOpenIndices()), indexToTableName), tablesFilter)); // Search for partitioned table templates UnmodifiableIterator<String> templates = clusterService.state().metaData().getTemplates().keysIt(); while (templates.hasNext()) { String templateName = templates.next(); if (!PartitionName.isPartition(templateName)) { continue; } try { PartitionName partitionName = PartitionName.fromIndexOrTemplate(templateName); TableIdent ti = partitionName.tableIdent(); if (schemaName.equalsIgnoreCase(ti.schema())) { tables.add(ti.name()); } } catch (IllegalArgumentException e) { // do nothing } } return tables; }
Example 8
Source File: ImmutableCollectionSerializers.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public void write(final Kryo kryo, final Output output, final ImmutableList<Object> object) { output.writeInt(object.size(), true); final UnmodifiableIterator iterator = object.iterator(); while (iterator.hasNext()) { final Object value = iterator.next(); kryo.writeClassAndObject(output, value); } }
Example 9
Source File: ImmutableCollectionSerializers.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public void write(final Kryo kryo, final Output output, final ImmutableSet<Object> object) { output.writeInt(object.size(), true); final UnmodifiableIterator iterator = object.iterator(); while (iterator.hasNext()) { final Object value = iterator.next(); kryo.writeClassAndObject(output, value); } }
Example 10
Source File: MultiUnifierImpl.java From grakn with GNU Affero General Public License v3.0 | 5 votes |
@Override public Unifier getAny() { UnmodifiableIterator<Unifier> iterator = multiUnifier.iterator(); if (!iterator.hasNext()){ throw ReasonerException.nonExistentUnifier(); } return iterator.next(); }
Example 11
Source File: InfluxHistory.java From monsoon with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public boolean addAll(@NonNull Iterator<? extends TimeSeriesCollection> i) { boolean changed = false; final UnmodifiableIterator<List<Map.Entry<DateTime, TimeSeriesValue>>> batchPointIter = asBatchPointIteration_(i); while (batchPointIter.hasNext()) { write_(batchPointIter.next()); changed = true; } return changed; }
Example 12
Source File: EventPoolImpl.java From neoscada with Eclipse Public License 1.0 | 4 votes |
private void loadFromStorage () { // load initial set from storage, but restrict it to *daysToRetrieve* days try { final long t = System.currentTimeMillis (); // retrieve data per day, to restrict database load for ( int daysBack = 1; daysBack <= daysToRetrieve; daysBack++ ) { final Calendar calStart = new GregorianCalendar (); final Calendar calEnd = new GregorianCalendar (); calStart.setTimeInMillis ( t ); calStart.add ( Calendar.DAY_OF_YEAR, -daysBack ); calEnd.setTimeInMillis ( t ); calEnd.add ( Calendar.DAY_OF_YEAR, -daysBack + 1 ); final StringBuilder filter = new StringBuilder (); filter.append ( "(&" ); if ( this.filter != null ) { filter.append ( this.filter ); } filter.append ( "(sourceTimestamp>=" + isoDateFormat.format ( calStart.getTime () ) + ")" ); if ( daysBack > 1 ) { filter.append ( "(sourceTimestamp<" + isoDateFormat.format ( calEnd.getTime () ) + ")" ); } filter.append ( ")" ); logger.debug ( "load events from filter: " + filter ); final Query query = this.storage.query ( filter.toString () ); try { int count; synchronized ( this ) { count = this.events.getCapacity (); } final Collection<Event> result = query.getNext ( count ); logger.debug ( "Loaded {} entries from storage", result.size () ); synchronized ( this ) { this.events.addAll ( result ); final UnmodifiableIterator<List<Event>> it = Iterators.partition ( this.events.iterator (), chunkSize ); while ( it.hasNext () ) { final List<org.eclipse.scada.ae.Event> chunk = it.next (); notifyEvent ( chunk ); } } } finally { query.dispose (); } if ( this.events.size () >= this.events.getCapacity () ) { return; } } logger.debug ( "load of events complete" ); } catch ( final Exception e ) { logger.error ( "loadFromStorage failed", e ); } }
Example 13
Source File: AaptStep.java From buck with Apache License 2.0 | 4 votes |
@Override protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) { ImmutableList.Builder<String> builder = ImmutableList.builder(); builder.addAll(androidPlatformTarget.getAaptExecutable().get().getCommandPrefix(pathResolver)); builder.add("package"); // verbose flag, if appropriate. if (context.getVerbosity().shouldUseVerbosityFlagIfAvailable()) { builder.add("-v"); } // Force overwrite of existing files. builder.add("-f"); builder.add("-G", pathToGeneratedProguardConfig.toString()); // --no-crunch, if appropriate. if (!isCrunchPngFiles) { builder.add("--no-crunch"); } // Include all of the res/ directories. builder.add("--auto-add-overlay"); for (Path res : MoreIterables.dedupKeepLast(resDirectories)) { builder.add("-S", res.toString()); } // Include the assets/ directory, if any. for (Path assetDir : assetsDirectories) { builder.add("-A", assetDir.toString()); } builder.add("--output-text-symbols").add(pathToRDotTxtDir.toString()); builder.add("-J").add(pathToRDotTxtDir.toString()); builder.add("-M").add(androidManifest.toString()); builder.add("-I", androidPlatformTarget.getAndroidJar().toString()); builder.add("-F", pathToOutputApkFile.toString()); builder.add("--ignore-assets", IGNORE_ASSETS_PATTERN); if (manifestEntries.getMinSdkVersion().isPresent()) { builder.add("--min-sdk-version", manifestEntries.getMinSdkVersion().get().toString()); } if (manifestEntries.getTargetSdkVersion().isPresent()) { builder.add("--target-sdk-version", manifestEntries.getTargetSdkVersion().get().toString()); } if (manifestEntries.getVersionCode().isPresent()) { builder.add("--version-code", manifestEntries.getVersionCode().get().toString()); } if (manifestEntries.getVersionName().isPresent()) { builder.add("--version-name", manifestEntries.getVersionName().get()); } if (manifestEntries.getDebugMode().orElse(false)) { builder.add("--debug-mode"); } if (manifestEntries.hasAny()) { // Force AAPT to error if the command line version clashes with the hardcoded manifest builder.add("--error-on-failed-insert"); } if (includesVectorDrawables) { builder.add("--no-version-vectors"); } UnmodifiableIterator<Path> iterator = pathToDependecyResourceApks.iterator(); if (iterator.hasNext()) { builder.add("--feature-of", iterator.next().toString()); } while (iterator.hasNext()) { builder.add("--feature-after", iterator.next().toString()); } builder.addAll(additionalAaptParams); return builder.build(); }