List of usage examples for com.google.common.collect ImmutableSet.Builder addAll
boolean addAll(Collection<? extends E> c);
From source file:com.facebook.buck.util.MorePosixFilePermissions.java
/** * Return a new set of permissions which include execute permission for each of the * roles that already have read permissions (e.g. 0606 => 0707). *///from w w w. j a v a 2 s. c o m public static ImmutableSet<PosixFilePermission> addExecutePermissionsIfReadable( Set<PosixFilePermission> permissions) { ImmutableSet.Builder<PosixFilePermission> newPermissions = ImmutableSet.builder(); // The new permissions are a superset of the current ones. newPermissions.addAll(permissions); // If we see a read permission for the given role, add in the corresponding // execute permission. for (ImmutableMap.Entry<PosixFilePermission, PosixFilePermission> ent : READ_TO_EXECUTE_MAP.entrySet()) { if (permissions.contains(ent.getKey())) { newPermissions.add(ent.getValue()); } } return newPermissions.build(); }
From source file:io.prestosql.sql.planner.SymbolsExtractor.java
public static Set<Symbol> extractUniqueNonRecursive(PlanNode node) { ImmutableSet.Builder<Symbol> uniqueSymbols = ImmutableSet.builder(); extractExpressionsNonRecursive(node).forEach(expression -> uniqueSymbols.addAll(extractUnique(expression))); return uniqueSymbols.build(); }
From source file:com.facebook.buck.apple.AppleLibraryDescriptionSwiftEnhancer.java
/** * Returns transitive preprocessor inputs excluding those from the swift delegate of the given * CxxLibrary.// w w w.j a v a2s .co m */ public static ImmutableSet<CxxPreprocessorInput> getPreprocessorInputsForAppleLibrary(BuildTarget target, ActionGraphBuilder graphBuilder, CxxPlatform platform, AppleNativeTargetDescriptionArg arg) { CxxLibrary lib = (CxxLibrary) graphBuilder.requireRule(target.withFlavors()); ImmutableMap<BuildTarget, CxxPreprocessorInput> transitiveMap = TransitiveCxxPreprocessorInputCache .computeTransitiveCxxToPreprocessorInputMap(platform, lib, false, graphBuilder); ImmutableSet.Builder<CxxPreprocessorInput> builder = ImmutableSet.builder(); builder.addAll(transitiveMap.values()); if (arg.isModular()) { Optional<CxxPreprocessorInput> underlyingModule = AppleLibraryDescription .underlyingModuleCxxPreprocessorInput(target, graphBuilder, platform); underlyingModule.ifPresent(builder::add); } else { builder.add(lib.getPublicCxxPreprocessorInputExcludingDelegate(platform, graphBuilder)); } return builder.build(); }
From source file:org.apache.aurora.benchmark.ThriftApiBenchmarks.java
private static void bulkLoadTasks(Storage storage, final TestConfiguration config) { // Ideally we would use the API to populate the storage, but wiring in the writable thrift // interface requires considerably more binding setup. storage.write((Storage.MutateWork.NoResult.Quiet) storeProvider -> { for (int roleId = 0; roleId < config.roles; roleId++) { String role = "role" + roleId; for (int envId = 0; envId < config.envs; envId++) { String env = "env" + envId; for (int jobId = 0; jobId < config.jobs; jobId++) { String job = "job" + jobId; ImmutableSet.Builder<IScheduledTask> tasks = ImmutableSet.builder(); tasks.addAll(new Tasks.Builder().setRole(role).setEnv(env).setJob(job) .setScheduleStatus(ScheduleStatus.RUNNING).build(config.instances)); tasks.addAll(new Tasks.Builder().setRole(role).setEnv(env).setJob(job) .setScheduleStatus(ScheduleStatus.FINISHED).build(config.deadTasks)); storeProvider.getUnsafeTaskStore().saveTasks(tasks.build()); }// w w w . j a va 2s .c om } } }); }
From source file:com.google.cloud.dataflow.sdk.options.PipelineOptionsReflector.java
/** * Retrieve metadata for the full set of pipeline options visible within the type hierarchy * closure of the set of input interfaces. An option is "visible" if: * <p>//from w ww .j av a2s .c o m * <ul> * <li>The option is defined within the interface hierarchy closure of the input * {@link PipelineOptions}.</li> * <li>The defining interface is not marked {@link Hidden}.</li> * </ul> */ static Set<PipelineOptionSpec> getOptionSpecs(Iterable<Class<? extends PipelineOptions>> optionsInterfaces) { ImmutableSet.Builder<PipelineOptionSpec> setBuilder = ImmutableSet.builder(); for (Class<? extends PipelineOptions> optionsInterface : optionsInterfaces) { setBuilder.addAll(getOptionSpecs(optionsInterface)); } return setBuilder.build(); }
From source file:com.twitter.common.net.pool.DynamicHostSetUtil.java
/** * Gets a snapshot of a set of dynamic hosts (e.g. a ServerSet) and returns a readable copy of * the underlying actual endpoints.//www .ja va2s. c o m * * @param hostSet The hostSet to snapshot. * @throws MonitorException if there was a problem obtaining the snapshot. */ public static <T> ImmutableSet<T> getSnapshot(DynamicHostSet<T> hostSet) throws MonitorException { final ImmutableSet.Builder<T> snapshot = ImmutableSet.builder(); Command unwatch = hostSet.watch(new HostChangeMonitor<T>() { @Override public void onChange(ImmutableSet<T> hostSet) { snapshot.addAll(hostSet); } }); unwatch.execute(); return snapshot.build(); }
From source file:dagger2.internal.codegen.writer.Snippet.java
public static Snippet format(String format, Object... args) { ImmutableSet.Builder<TypeName> types = ImmutableSet.builder(); for (Object arg : args) { if (arg instanceof Snippet) { types.addAll(((Snippet) arg).types); }/*from www.j a v a2 s . co m*/ if (arg instanceof TypeName) { types.add((TypeName) arg); } if (arg instanceof HasTypeName) { types.add(((HasTypeName) arg).name()); } } return new Snippet(format, types.build(), ImmutableList.copyOf(args)); }
From source file:com.google.devtools.j2objc.gen.GeneratedType.java
public static GeneratedType fromTypeDeclaration(AbstractTypeDeclaration typeNode) { ITypeBinding typeBinding = typeNode.getTypeBinding(); CompilationUnit unit = TreeUtil.getCompilationUnit(typeNode); NameTable nameTable = unit.getNameTable(); ImmutableList.Builder<String> superTypes = ImmutableList.builder(); ITypeBinding superclass = typeBinding.getSuperclass(); if (superclass != null) { superTypes.add(nameTable.getFullName(superclass)); }/* www. j av a 2 s . com*/ for (ITypeBinding superInterface : typeBinding.getInterfaces()) { superTypes.add(nameTable.getFullName(superInterface)); } HeaderImportCollector headerCollector = new HeaderImportCollector(HeaderImportCollector.Filter.PUBLIC_ONLY); headerCollector.collect(typeNode); HeaderImportCollector privateDeclarationCollector = new HeaderImportCollector( HeaderImportCollector.Filter.PRIVATE_ONLY); privateDeclarationCollector.collect(typeNode); ImplementationImportCollector importCollector = new ImplementationImportCollector(); importCollector.collect(typeNode); SourceBuilder builder = new SourceBuilder(Options.emitLineDirectives()); TypeDeclarationGenerator.generate(builder, typeNode); String publicDeclarationCode = builder.toString(); builder = new SourceBuilder(Options.emitLineDirectives()); TypePrivateDeclarationGenerator.generate(builder, typeNode); String privateDeclarationCode = builder.toString(); builder = new SourceBuilder(Options.emitLineDirectives()); TypeImplementationGenerator.generate(builder, typeNode); String implementationCode = builder.toString(); ImmutableSet.Builder<Import> implementationIncludes = ImmutableSet.builder(); implementationIncludes.addAll(privateDeclarationCollector.getSuperTypes()); implementationIncludes.addAll(importCollector.getImports()); return new GeneratedType(nameTable.getFullName(typeBinding), typeNode.hasPrivateDeclaration(), superTypes.build(), ImmutableSet.copyOf(headerCollector.getForwardDeclarations()), ImmutableSet.copyOf(headerCollector.getSuperTypes()), ImmutableSet.copyOf(privateDeclarationCollector.getForwardDeclarations()), implementationIncludes.build(), publicDeclarationCode, privateDeclarationCode, implementationCode); }
From source file:com.google.idea.blaze.base.lang.buildfile.language.semantics.BuiltInNamesProvider.java
/** Returns all built-in rules and function names. */ public static ImmutableSet<String> getBuiltInFunctionNames(Project project) { ImmutableSet.Builder<String> builder = ImmutableSet.<String>builder().addAll(FUNCTIONS); BuildLanguageSpec spec = BuildLanguageSpecProvider.getInstance().getLanguageSpec(project); if (spec != null) { builder = builder.addAll(spec.getKnownRuleNames()); }//from ww w. j a va 2 s . com return builder.build(); }
From source file:com.facebook.buck.jvm.java.JavaLibraryClasspathProvider.java
/** * Include the classpath entries from all JavaLibraryRules that have a direct line of lineage * to this rule through other JavaLibraryRules. For example, in the following dependency graph: * * A/* w ww. j a v a 2 s. c om*/ * / \ * B C * / \ / \ * D E F G * * If all of the nodes correspond to BuildRules that implement JavaLibraryRule except for * B (suppose B is a Genrule), then A's classpath will include C, F, and G, but not D and E. * This is because D and E are used to generate B, but do not contribute .class files to things * that depend on B. However, if C depended on E as well as F and G, then E would be included in * A's classpath. */ public static ImmutableSet<JavaLibrary> getClasspathDeps(Iterable<BuildRule> deps) { ImmutableSet.Builder<JavaLibrary> classpathDeps = ImmutableSet.builder(); for (BuildRule dep : deps) { if (dep instanceof HasClasspathEntries) { classpathDeps.addAll(((HasClasspathEntries) dep).getTransitiveClasspathDeps()); } } return classpathDeps.build(); }