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();
}
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();
}
}
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();
}
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();
}
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();
}
Aggregations