List of usage examples for com.google.common.collect ImmutableList.Builder addAll
boolean addAll(Collection<? extends E> c);
From source file:com.facebook.presto.metadata.SqlScalarFunctionBuilder.java
@SafeVarargs public static Function<SpecializeContext, List<Object>> concat( Function<SpecializeContext, List<Object>>... extraParametersFunctions) { return context -> { ImmutableList.Builder<Object> extraParametersBuilder = ImmutableList.builder(); for (Function<SpecializeContext, List<Object>> extraParametersFunction : extraParametersFunctions) { extraParametersBuilder.addAll(extraParametersFunction.apply(context)); }/*from www .ja v a 2 s.c o m*/ return extraParametersBuilder.build(); }; }
From source file:com.facebook.buck.features.haskell.HaskellGhciDescription.java
/** Give a rule for an omnibus object to be loaded into a ghci session */ public static synchronized BuildRule requireOmnibusSharedObject(CellPathResolver cellPathResolver, BuildTarget baseTarget, ProjectFilesystem projectFilesystem, ActionGraphBuilder graphBuilder, CxxPlatform cxxPlatform, CxxBuckConfig cxxBuckConfig, Iterable<NativeLinkable> body, Iterable<NativeLinkable> deps, ImmutableList<Arg> extraLdFlags) { return graphBuilder.computeIfAbsent( baseTarget.withShortName(baseTarget.getShortName() + ".omnibus-shared-object"), ruleTarget -> { ImmutableList.Builder<Arg> linkFlagsBuilder = ImmutableList.builder(); linkFlagsBuilder.addAll(extraLdFlags); linkFlagsBuilder/*www. java 2 s .com*/ .addAll(getOmnibusNativeLinkableInput(baseTarget, cxxPlatform, graphBuilder, body, deps) .getArgs()); // ---------------------------------------------------------------- // Add to graphBuilder return CxxLinkableEnhancer.createCxxLinkableSharedBuildRule(cxxBuckConfig, cxxPlatform, projectFilesystem, graphBuilder, new SourcePathRuleFinder(graphBuilder), ruleTarget, BuildTargetPaths.getGenPath(projectFilesystem, ruleTarget, "%s") .resolve("libghci_dependencies.so"), ImmutableMap.of(), Optional.of("libghci_dependencies.so"), linkFlagsBuilder.build(), cellPathResolver); }); }
From source file:com.facebook.buck.util.env.BuckClasspath.java
/** * Return Buck's classpath when running under Intellij. Use getClasspath() or * getBootstrapClasspath() instead.//w w w .j av a 2 s . c o m */ public static ImmutableList<Path> getBuckClasspathForIntellij() throws IOException { ImmutableList.Builder<Path> classPathEntries = ImmutableList.builder(); Path productionPath = getClassLocation(BuckClasspath.class); classPathEntries.add(productionPath.toAbsolutePath()); Path testPath = productionPath.resolve("../../test/buck").normalize(); classPathEntries.add(testPath.toAbsolutePath()); classPathEntries.addAll(filterAntClasspaths(readClasspaths(Paths.get("programs", "classpaths")))); classPathEntries.addAll(filterAntClasspaths(readClasspaths(Paths.get("programs", "test_classpaths")))); return classPathEntries.build(); }
From source file:com.facebook.presto.operator.UnnestOperator.java
private static List<Type> getUnnestedTypes(List<Type> types) { ImmutableList.Builder<Type> builder = ImmutableList.builder(); for (Type type : types) { checkArgument(type instanceof ArrayType || type instanceof MapType, "Can only unnest map and array types"); builder.addAll(type.getTypeParameters()); }// w ww .j av a2 s . co m return builder.build(); }
From source file:org.fcrepo.transform.transformations.LDPathTransform.java
/** * Pull a node-type specific transform out of JCR * @param node/*from w w w .ja v a 2 s. co m*/ * @param key * @return * @throws RepositoryException */ public static LDPathTransform getNodeTypeTransform(final Node node, final String key) throws RepositoryException { final Node programNode = node.getSession().getNode(CONFIGURATION_FOLDER + key); LOGGER.debug("Found program node: {}", programNode.getPath()); final NodeType primaryNodeType = node.getPrimaryNodeType(); final Set<NodeType> supertypes = orderedBy(nodeTypeComp).add(primaryNodeType.getSupertypes()).build(); final Set<NodeType> mixinTypes = orderedBy(nodeTypeComp).add(node.getMixinNodeTypes()).build(); // start with mixins, primary type, and supertypes of primary type final ImmutableList.Builder<NodeType> nodeTypesB = new ImmutableList.Builder<NodeType>().addAll(mixinTypes) .add(primaryNodeType).addAll(supertypes); // add supertypes of mixins for (final NodeType mixin : mixinTypes) { nodeTypesB.addAll(orderedBy(nodeTypeComp).add(mixin.getDeclaredSupertypes()).build()); } final List<NodeType> nodeTypes = nodeTypesB.build(); LOGGER.debug("Discovered node types: {}", nodeTypes); for (final NodeType nodeType : nodeTypes) { if (programNode.hasNode(nodeType.toString())) { return new LDPathTransform(programNode.getNode(nodeType.toString()).getNode(JCR_CONTENT) .getProperty(JCR_DATA).getBinary().getStream()); } } throw new WebApplicationException( new Exception( "Couldn't find transformation for " + node.getPath() + " and transformation key " + key), SC_BAD_REQUEST); }
From source file:com.google.javascript.jscomp.JsChecker.java
private static ImmutableList<SourceFile> getSourceFiles(Iterable<String> filenames) throws IOException { ImmutableList.Builder<SourceFile> result = new ImmutableList.Builder<>(); for (String filename : filenames) { if (filename.endsWith(".zip")) { result.addAll(SourceFile.fromZipFile(filename, UTF_8)); } else {/*from w w w .j a v a 2s . co m*/ result.add(SourceFile.fromFile(filename)); } } return result.build(); }
From source file:com.spotify.heroic.metric.ResultGroups.java
public static Collector<ResultGroups, ResultGroups> collect(final QueryTrace.Identifier what) { final Stopwatch w = Stopwatch.createStarted(); return results -> { final ImmutableList.Builder<ResultGroup> groups = ImmutableList.builder(); final ImmutableList.Builder<RequestError> errors = ImmutableList.builder(); final ImmutableList.Builder<QueryTrace> traces = ImmutableList.builder(); Statistics statistics = Statistics.empty(); for (final ResultGroups r : results) { groups.addAll(r.groups); errors.addAll(r.errors);/*from w ww.ja va 2s .c o m*/ traces.add(r.trace); statistics = statistics.merge(r.statistics); } return new ResultGroups(groups.build(), errors.build(), statistics, new QueryTrace(what, w.elapsed(TimeUnit.NANOSECONDS), traces.build())); }; }
From source file:com.google.devtools.build.lib.skyframe.TargetPatternUtil.java
/** * Expand the given {@code targetPatterns}, using the {@code filteringPolicy}. This handles the * needed underlying Skyframe calls (via {@code env}), and no will return {@code null} to signal a * Skyframe restart.//from w ww. j av a2s. c o m */ @Nullable public static ImmutableList<Label> expandTargetPatterns(Environment env, List<String> targetPatterns, FilteringPolicy filteringPolicy) throws InvalidTargetPatternException, InterruptedException { // First parse the patterns, and throw any errors immediately. List<TargetPatternValue.TargetPatternKey> patternKeys = new ArrayList<>(); for (TargetPatternValue.TargetPatternSkyKeyOrException keyOrException : TargetPatternValue .keys(targetPatterns, filteringPolicy, "")) { try { patternKeys.add(keyOrException.getSkyKey()); } catch (TargetParsingException e) { throw new InvalidTargetPatternException(keyOrException.getOriginalPattern(), e); } } // Then, resolve the patterns. Map<SkyKey, ValueOrException<TargetParsingException>> resolvedPatterns = env.getValuesOrThrow(patternKeys, TargetParsingException.class); boolean valuesMissing = env.valuesMissing(); ImmutableList.Builder<Label> labels = valuesMissing ? null : new ImmutableList.Builder<>(); for (TargetPatternValue.TargetPatternKey pattern : patternKeys) { TargetPatternValue value; try { value = (TargetPatternValue) resolvedPatterns.get(pattern).get(); if (!valuesMissing && value != null) { labels.addAll(value.getTargets().getTargets()); } } catch (TargetParsingException e) { throw new InvalidTargetPatternException(pattern.getPattern(), e); } } if (valuesMissing) { return null; } return labels.build(); }
From source file:com.google.devtools.build.lib.rules.android.AndroidResources.java
private static ImmutableList<Artifact> getResources(Iterable<FileProvider> targets) { ImmutableList.Builder<Artifact> builder = ImmutableList.builder(); for (FileProvider target : targets) { builder.addAll(target.getFilesToBuild()); }//ww w.j a va2 s.c o m return builder.build(); }
From source file:com.wrmsr.wava.analyze.ControlFlowGraph.java
private static void putFlow(ImmutableList.Builder<Edge> edges, Node node, List<Edge> inputs) { checkArgument(inputs.stream().allMatch(e -> e.output == PLACEHOLDER)); edges.addAll(inputs.stream().map(e -> new Edge(e.type, e.input, node)).iterator()); }