Search in sources :

Example 91 with ImmutableSet

use of com.google.common.collect.ImmutableSet in project GeoGig by boundlessgeo.

the class ForEachRef method _call.

/**
     * @return the new value of the ref
     */
@Override
protected ImmutableSet<Ref> _call() {
    @SuppressWarnings("unchecked") final Predicate<Ref> filter = (Predicate<Ref>) (this.filter == null ? Predicates.alwaysTrue() : this.filter);
    ImmutableSet.Builder<Ref> refs = new ImmutableSet.Builder<Ref>();
    for (String refName : refDatabase().getAll().keySet()) {
        Optional<Ref> ref = command(RefParse.class).setName(refName).call();
        if (ref.isPresent() && filter.apply(ref.get())) {
            Ref accepted = ref.get();
            refs.add(accepted);
        }
    }
    return refs.build();
}
Also used : Ref(org.locationtech.geogig.api.Ref) ImmutableSet(com.google.common.collect.ImmutableSet) Predicate(com.google.common.base.Predicate)

Example 92 with ImmutableSet

use of com.google.common.collect.ImmutableSet in project uPortal by Jasig.

the class MarketplaceService method browseableMarketplaceEntriesFor.

@Override
public ImmutableSet<MarketplaceEntry> browseableMarketplaceEntriesFor(final IPerson user, final Set<PortletCategory> categories) {
    Element cacheElement = marketplaceUserPortletDefinitionCache.get(user.getUserName());
    Future<ImmutableSet<MarketplaceEntry>> future = null;
    if (cacheElement == null) {
        // not in cache, load it and cache the results...
        future = loadMarketplaceEntriesFor(user, categories);
    } else {
        future = (Future<ImmutableSet<MarketplaceEntry>>) cacheElement.getObjectValue();
    }
    try {
        return future.get();
    } catch (InterruptedException | ExecutionException e) {
        logger.error(e.getMessage(), e);
        return ImmutableSet.of();
    }
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Element(net.sf.ehcache.Element) ExecutionException(java.util.concurrent.ExecutionException)

Example 93 with ImmutableSet

use of com.google.common.collect.ImmutableSet in project gradle by gradle.

the class DefaultTaskExecutionPlan method canonicalizedPaths.

private static ImmutableSet<String> canonicalizedPaths(final Map<File, String> cache, Iterable<File> files) {
    ImmutableSet.Builder<String> builder = ImmutableSet.builder();
    for (File file : files) {
        String path;
        try {
            path = cache.get(file);
            if (path == null) {
                path = file.getCanonicalPath();
                cache.put(file, path);
            }
            builder.add(path);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }
    return builder.build();
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) UncheckedIOException(org.gradle.api.UncheckedIOException) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) File(java.io.File)

Example 94 with ImmutableSet

use of com.google.common.collect.ImmutableSet in project gradle by gradle.

the class FileToArchiveEntrySetTransformer method walk.

private ImmutableSet<ArchiveEntry> walk(InputStream archiveInputStream, ImmutableSet.Builder<ArchiveEntry> allEntries, ImmutableList<String> parentPaths) {
    ImmutableSet.Builder<ArchiveEntry> entries = ImmutableSet.builder();
    ZipInputStream zipStream = new ZipInputStream(archiveInputStream);
    try {
        ZipEntry entry = zipStream.getNextEntry();
        while (entry != null) {
            ArchiveEntry.Builder builder = new ArchiveEntry.Builder();
            builder.setParentPaths(parentPaths);
            builder.setPath(entry.getName());
            builder.setCrc(entry.getCrc());
            builder.setDirectory(entry.isDirectory());
            builder.setSize(entry.getSize());
            if (!builder.isDirectory() && (zipStream.available() == 1)) {
                boolean zipEntry;
                final BufferedInputStream bis = new BufferedInputStream(zipStream) {

                    @Override
                    public void close() throws IOException {
                    }
                };
                bis.mark(Integer.MAX_VALUE);
                zipEntry = new ZipInputStream(bis).getNextEntry() != null;
                bis.reset();
                if (zipEntry) {
                    ImmutableList<String> nextParentPaths = ImmutableList.<String>builder().addAll(parentPaths).add(entry.getName()).build();
                    ImmutableSet<ArchiveEntry> subEntries = walk(bis, allEntries, nextParentPaths);
                    builder.setSubEntries(subEntries);
                }
            }
            ArchiveEntry archiveEntry = builder.build();
            entries.add(archiveEntry);
            allEntries.add(archiveEntry);
            zipStream.closeEntry();
            entry = zipStream.getNextEntry();
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    } finally {
        IOUtils.closeQuietly(zipStream);
    }
    return entries.build();
}
Also used : ZipEntry(java.util.zip.ZipEntry) UncheckedIOException(org.gradle.api.UncheckedIOException) UncheckedIOException(org.gradle.api.UncheckedIOException) ZipInputStream(java.util.zip.ZipInputStream) ImmutableSet(com.google.common.collect.ImmutableSet)

Example 95 with ImmutableSet

use of com.google.common.collect.ImmutableSet in project gradle by gradle.

the class CacheBackedTaskHistoryRepository method getDeclaredOutputFilePaths.

private static ImmutableSet<String> getDeclaredOutputFilePaths(final TaskProperties taskProperties, final StringInterner stringInterner) {
    final ImmutableSet.Builder<String> declaredOutputFilePaths = ImmutableSortedSet.naturalOrder();
    FileCollectionInternal outputFiles = (FileCollectionInternal) taskProperties.getOutputFiles();
    outputFiles.visitRootElements(new FileCollectionVisitor() {

        @Override
        public void visitCollection(FileCollectionInternal fileCollection) {
            addAllPaths(fileCollection, declaredOutputFilePaths, stringInterner);
        }

        @Override
        public void visitTree(FileTreeInternal fileTree) {
            DeprecationLogger.nagUserOfDeprecated("Adding file trees which are not directory trees as output files");
            addAllPaths(fileTree, declaredOutputFilePaths, stringInterner);
        }

        @Override
        public void visitDirectoryTree(DirectoryFileTree directoryTree) {
            addPath(directoryTree.getDir(), declaredOutputFilePaths, stringInterner);
        }
    });
    return declaredOutputFilePaths.build();
}
Also used : FileCollectionVisitor(org.gradle.api.internal.file.FileCollectionVisitor) ImmutableSet(com.google.common.collect.ImmutableSet) FileCollectionInternal(org.gradle.api.internal.file.FileCollectionInternal) DirectoryFileTree(org.gradle.api.internal.file.collections.DirectoryFileTree) FileTreeInternal(org.gradle.api.internal.file.FileTreeInternal)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)212 Path (java.nio.file.Path)66 BuildTarget (com.facebook.buck.model.BuildTarget)58 ImmutableList (com.google.common.collect.ImmutableList)48 ImmutableMap (com.google.common.collect.ImmutableMap)48 IOException (java.io.IOException)43 Optional (java.util.Optional)39 Test (org.junit.Test)35 SourcePath (com.facebook.buck.rules.SourcePath)31 Set (java.util.Set)31 Map (java.util.Map)30 TargetNode (com.facebook.buck.rules.TargetNode)28 List (java.util.List)28 BuildRule (com.facebook.buck.rules.BuildRule)26 HumanReadableException (com.facebook.buck.util.HumanReadableException)23 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)22 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)21 HashMap (java.util.HashMap)21 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)20 VisibleForTesting (com.google.common.annotations.VisibleForTesting)20