List of usage examples for com.google.common.collect ImmutableCollection iterator
public abstract UnmodifiableIterator<E> iterator();
From source file:com.facebook.buck.android.AndroidNdkHelper.java
public static NdkCxxPlatform getNdkCxxPlatform(ProjectWorkspace workspace, ProjectFilesystem filesystem) throws IOException, InterruptedException { // TODO(cjhopman): is this really the simplest way to get the objdump tool? AndroidDirectoryResolver androidResolver = new DefaultAndroidDirectoryResolver( workspace.asCell().getRoot().getFileSystem(), ImmutableMap.copyOf(System.getenv()), Optional.empty(), Optional.empty()); Optional<Path> ndkPath = androidResolver.getNdkOrAbsent(); assertTrue(ndkPath.isPresent());/* w ww. j ava2 s. c om*/ Optional<String> ndkVersion = DefaultAndroidDirectoryResolver.findNdkVersionFromDirectory(ndkPath.get()); String gccVersion = NdkCxxPlatforms.getDefaultGccVersionForNdk(ndkVersion); ImmutableCollection<NdkCxxPlatform> platforms = NdkCxxPlatforms .getPlatforms(CxxPlatformUtils.DEFAULT_CONFIG, filesystem, ndkPath.get(), NdkCxxPlatformCompiler.builder().setType(NdkCxxPlatforms.DEFAULT_COMPILER_TYPE) .setVersion(gccVersion).setGccVersion(gccVersion).build(), NdkCxxPlatforms.DEFAULT_CXX_RUNTIME, NdkCxxPlatforms.DEFAULT_TARGET_APP_PLATFORM, NdkCxxPlatforms.DEFAULT_CPU_ABIS, Platform.detect()) .values(); assertFalse(platforms.isEmpty()); return platforms.iterator().next(); }
From source file:com.facebook.buck.android.toolchain.ndk.impl.AndroidNdkHelper.java
public static NdkCxxPlatform getNdkCxxPlatform(ProjectFilesystem filesystem) { // TODO(cjhopman): is this really the simplest way to get the objdump tool? Optional<AndroidNdk> androidNdk = detectAndroidNdk(filesystem); Path ndkPath = androidNdk.get().getNdkRootPath(); String ndkVersion = AndroidNdkResolver.findNdkVersionFromDirectory(ndkPath).get(); String gccVersion = NdkCxxPlatforms.getDefaultGccVersionForNdk(ndkVersion); String clangVersion = NdkCxxPlatforms.getDefaultClangVersionForNdk(ndkVersion); NdkCompilerType compilerType = NdkCxxPlatforms.getDefaultCompilerTypeForNdk(ndkVersion); NdkCxxRuntime cxxRuntime = NdkCxxPlatforms.getDefaultCxxRuntimeForNdk(ndkVersion); String compilerVersion = compilerType == NdkCompilerType.GCC ? gccVersion : clangVersion; ImmutableCollection<UnresolvedNdkCxxPlatform> platforms = NdkCxxPlatforms .getPlatforms(CxxPlatformUtils.DEFAULT_CONFIG, AndroidNdkHelper.DEFAULT_CONFIG, filesystem, ndkPath, NdkCxxPlatformCompiler.builder().setType(compilerType).setVersion(compilerVersion) .setGccVersion(gccVersion).build(), cxxRuntime, NdkCxxRuntimeType.DYNAMIC, getDefaultCpuAbis(ndkVersion), Platform.detect()) .values();/*from w ww.ja va2s . c om*/ assertFalse(platforms.isEmpty()); return platforms.iterator().next().resolve(new TestActionGraphBuilder()); }
From source file:com.spectralogic.ds3client.helpers.RangeHelper.java
static ImmutableCollection<Range> replaceRange(final ImmutableCollection<Range> existingRanges, final long numBytesTransferred, final long intendedNumBytesToTransfer) { Preconditions.checkState(numBytesTransferred >= 0, "numBytesTransferred must be >= 0."); Preconditions.checkState(intendedNumBytesToTransfer > 0, "intendedNumBytesToTransfer must be > 0."); Preconditions.checkState(intendedNumBytesToTransfer > numBytesTransferred, "intendedNumBytesToTransfer must be > numBytesTransferred"); if (Guard.isNullOrEmpty(existingRanges)) { return ImmutableList .of(Range.byLength(numBytesTransferred, intendedNumBytesToTransfer - numBytesTransferred)); }/*w ww . j a v a 2s .co m*/ final ImmutableList.Builder<Range> newRangesbuilder = ImmutableList.builder(); final UnmodifiableIterator<Range> existingRangesIterator = existingRanges.iterator(); long previousAccumulatedBytesInRanges = 0; long currentAccumulatedBytesInRanges = existingRanges.iterator().next().getLength(); while (existingRangesIterator.hasNext()) { final Range existingRange = existingRangesIterator.next(); if (numBytesTransferred < currentAccumulatedBytesInRanges) { final Range firstNewRange = Range.byPosition( existingRange.getStart() - previousAccumulatedBytesInRanges + numBytesTransferred, existingRange.getEnd()); newRangesbuilder.add(firstNewRange); addRemainingRanges(existingRangesIterator, newRangesbuilder); break; } previousAccumulatedBytesInRanges += existingRange.getLength(); currentAccumulatedBytesInRanges += existingRange.getLength(); } return newRangesbuilder.build(); }
From source file:com.spectralogic.ds3client.helpers.strategy.transferstrategy.RangeHelper.java
protected static ImmutableCollection<Range> replaceRange(final ImmutableCollection<Range> existingRanges, final long numBytesTransferred, final long intendedNumBytesToTransfer) { Preconditions.checkState(numBytesTransferred >= 0, "numBytesTransferred must be >= 0."); Preconditions.checkState(intendedNumBytesToTransfer > 0, "intendedNumBytesToTransfer must be > 0."); Preconditions.checkState(intendedNumBytesToTransfer > numBytesTransferred, "intendedNumBytesToTransfer must be > numBytesTransferred"); if (Guard.isNullOrEmpty(existingRanges)) { return ImmutableList .of(Range.byLength(numBytesTransferred, intendedNumBytesToTransfer - numBytesTransferred)); }//from w w w . j a va 2s.c o m final ImmutableList.Builder<Range> newRangesbuilder = ImmutableList.builder(); final UnmodifiableIterator<Range> existingRangesIterator = existingRanges.iterator(); long previousAccumulatedBytesInRanges = 0; long currentAccumulatedBytesInRanges = existingRanges.iterator().next().getLength(); while (existingRangesIterator.hasNext()) { final Range existingRange = existingRangesIterator.next(); if (numBytesTransferred < currentAccumulatedBytesInRanges) { final Range firstNewRange = Range.byPosition( existingRange.getStart() - previousAccumulatedBytesInRanges + numBytesTransferred, existingRange.getEnd()); newRangesbuilder.add(firstNewRange); addRemainingRanges(existingRangesIterator, newRangesbuilder); break; } previousAccumulatedBytesInRanges += existingRange.getLength(); currentAccumulatedBytesInRanges += existingRange.getLength(); } return newRangesbuilder.build(); }
From source file:com.outerspacecat.util.ConcurrentNamespaceContext.java
@Override public String getPrefix(final String namespaceURI) { Preconditions.checkArgument(namespaceURI != null, "namespaceURI required"); ImmutableCollection<String> prefixes = namespaceMap.get(namespaceURI); if (prefixes.isEmpty()) return XMLConstants.NULL_NS_URI; return prefixes.iterator().next(); }
From source file:org.jetbrains.android.util.InstantAppUrlFinder.java
/** * Gets the default URL for this manifest. Returns an empty string if no URLs are found. * * @return/*from www. j av a 2 s.c o m*/ */ @NotNull public String getDefaultUrl() { ImmutableCollection<String> urls = getAllUrls(); if (!urls.isEmpty()) { return urls.iterator().next(); } return ""; }
From source file:com.torodb.torod.db.executor.jobs.InsertSplitDocumentCallable.java
private void insertSingleDoc(SplitDocument doc) throws ImplementationDbException, UserDbException { DbConnection connection = connectionProvider.get(); connection.insertRootDocuments(collection, Collections.singleton(doc)); for (SubDocType type : doc.getSubDocuments().rowKeySet()) { ImmutableCollection<SubDocument> subDocs = doc.getSubDocuments().row(type).values(); connection.insertSubdocuments(collection, type, subDocs.iterator()); }//from w ww . j av a 2s . c o m }
From source file:com.torodb.torod.db.executor.jobs.InsertCallable.java
private void insertSingleDoc(SplitDocument doc) throws ImplementationDbException, UserDbException { DbConnection connection = getConnection(); connection.insertRootDocuments(collection, Collections.singleton(doc)); for (SubDocType type : doc.getSubDocuments().rowKeySet()) { ImmutableCollection<SubDocument> subDocs = doc.getSubDocuments().row(type).values(); connection.insertSubdocuments(collection, type, subDocs.iterator()); }/* w w w . j a va 2 s . c om*/ }
From source file:com.outerspacecat.icalendar.Component.java
/** * Returns a single {@link Property} with the specified name, or {@code null} * if no such property exists. This method provides an easy way to ignore * extra properties. Which property is returned is non-deterministic, however * the same property will be returned each time this method is called. * /* ww w . java2 s . c o m*/ * @param name the name of the property to retrieve. Must be non {@code null}. * @return a single {@link Property} with the specified name, or {@code null} * if no such property exists. */ public Property getFirstProperty(final String name) { Preconditions.checkNotNull(name, "name required"); ImmutableCollection<Property> props = getProperties().get(name.toUpperCase()); return props.isEmpty() ? null : props.iterator().next(); }
From source file:com.spotify.docker.client.DockerConfigReader.java
/** * Return a single RegistryAuth from the config file. * If there are multiple RegistryAuth entries, which entry is returned from this method * depends on hashing and should not be considered reliable. * If there is only one entry, however, that will be the one returned. This is the * primary use of this method, as a useful way to extract a RegistryAuth during testing. * In that environment, the contents of the config file are known and controlled. In a * production environment, the contents of the config file are less predictable. * * @param configPath Path to the docker config file. * @return Some registry auth value./* ww w . j a v a 2 s . c o m*/ */ @VisibleForTesting RegistryAuth anyRegistryAuth(final Path configPath) throws IOException { final ImmutableCollection<RegistryAuth> registryAuths = authForAllRegistries(configPath).configs().values(); return registryAuths.isEmpty() ? RegistryAuth.builder().build() : registryAuths.iterator().next(); }