List of usage examples for com.google.common.collect ImmutableList builder
public static <E> Builder<E> builder()
From source file:com.bendb.thrifty.schema.ServiceMethod.java
public ServiceMethod(FunctionElement element) { this.element = element; ImmutableList.Builder<Field> params = ImmutableList.builder(); for (FieldElement field : element.params()) { params.add(new Field(field, FieldNamingPolicy.DEFAULT)); }//from w w w. j ava 2 s. c om this.paramTypes = params.build(); ImmutableList.Builder<Field> exceptions = ImmutableList.builder(); for (FieldElement field : element.exceptions()) { exceptions.add(new Field(field, FieldNamingPolicy.DEFAULT)); } this.exceptionTypes = exceptions.build(); ImmutableMap.Builder<String, String> annotationBuilder = ImmutableMap.builder(); AnnotationElement anno = element.annotations(); if (anno != null) { annotationBuilder.putAll(anno.values()); } this.annotations = annotationBuilder.build(); }
From source file:com.facebook.buck.rules.UberRDotJavaUtil.java
/** * Adds the commands to generate and compile the {@code R.java} files. The {@code .class} files * will be written to {@link #getPathToCompiledRDotJavaFiles(BuildTarget)}. *///from ww w. java 2 s .co m public static void generateRDotJavaFiles(Set<String> resDirectories, Set<String> rDotJavaPackages, BuildTarget buildTarget, ImmutableList.Builder<Step> commands) { // Create the path where the R.java files will be generated. String rDotJavaSrc = String.format("%s/%s__%s_uber_rdotjava_src__", BuckConstant.BIN_DIR, buildTarget.getBasePathWithSlash(), buildTarget.getShortName()); commands.add(new MakeCleanDirectoryStep(rDotJavaSrc)); // Generate the R.java files. GenRDotJavaStep genRDotJava = new GenRDotJavaStep(resDirectories, rDotJavaSrc, rDotJavaPackages.iterator().next(), /* isTempRDotJava */ false, rDotJavaPackages); commands.add(genRDotJava); // Create the path where the R.java files will be compiled. String rDotJavaBin = getPathToCompiledRDotJavaFiles(buildTarget); commands.add(new MakeCleanDirectoryStep(rDotJavaBin)); // Compile the R.java files. Set<String> javaSourceFilePaths = Sets.newHashSet(); for (String rDotJavaPackage : rDotJavaPackages) { String path = rDotJavaSrc + "/" + rDotJavaPackage.replace('.', '/') + "/R.java"; javaSourceFilePaths.add(path); } JavacInMemoryStep javac = createJavacInMemoryCommandForRDotJavaFiles(javaSourceFilePaths, rDotJavaBin); commands.add(javac); }
From source file:com.spectralogic.ds3autogen.net.generators.typemodels.NoneEnumGenerator.java
/** * Converts a list of Ds3EnumConstants into a list of Enum Constants and * adds the enum constant NONE/* w w w .ja v a2s . c o m*/ */ @Override public ImmutableList<EnumConstant> toEnumConstantsList(final ImmutableList<Ds3EnumConstant> ds3EnumConstants) { final ImmutableList.Builder<EnumConstant> builder = ImmutableList.builder(); builder.addAll(getEnumConstantsList(ds3EnumConstants)); builder.add(new EnumConstant("NONE")); return builder.build(); }
From source file:com.google.devtools.build.lib.rules.objc.XibFiles.java
/** * Returns a sequence where each element of this sequence is converted to the file which contains * the compiled contents of the xib./*from www .j a va 2 s .c o m*/ */ public ImmutableList<Artifact> compiledZips(IntermediateArtifacts intermediateArtifacts) { ImmutableList.Builder<Artifact> zips = new ImmutableList.Builder<>(); for (Artifact xib : this) { zips.add(intermediateArtifacts.compiledXibFileZip(xib)); } return zips.build(); }
From source file:io.prestosql.plugin.example.ExampleRecordSet.java
public ExampleRecordSet(ExampleSplit split, List<ExampleColumnHandle> columnHandles) { requireNonNull(split, "split is null"); this.columnHandles = requireNonNull(columnHandles, "column handles is null"); ImmutableList.Builder<Type> types = ImmutableList.builder(); for (ExampleColumnHandle column : columnHandles) { types.add(column.getColumnType()); }//from w ww. j av a2 s . c om this.columnTypes = types.build(); try { byteSource = Resources.asByteSource(split.getUri().toURL()); } catch (MalformedURLException e) { throw new RuntimeException(e); } }
From source file:ch.ledcom.jpreseed.distro.DistroService.java
public DistroService(List<Distribution> distributions) { ImmutableMap.Builder<String, Distribution> byNameBuilder = ImmutableMap.builder(); ImmutableList.Builder<DistroAndVersion> flattenedBuilder = ImmutableList.builder(); for (Distribution distro : distributions) { byNameBuilder.put(distro.getName(), distro); for (DistroVersion version : distro.getVersions()) { flattenedBuilder.add(new DistroAndVersion(distro, version)); }/*from w w w. ja va2 s . c o m*/ } this.distributionsByName = byNameBuilder.build(); this.flattenedVersions = flattenedBuilder.build(); }
From source file:com.facebook.buck.file.downloader.impl.StackedDownloader.java
public static Downloader createFromConfig(BuckConfig config, ToolchainProvider toolchainProvider) { ImmutableList.Builder<Downloader> downloaders = ImmutableList.builder(); DownloadConfig downloadConfig = new DownloadConfig(config); Optional<Proxy> proxy = downloadConfig.getProxy(); HttpDownloader httpDownloader = new HttpDownloader(proxy); for (Map.Entry<String, String> kv : downloadConfig.getAllMavenRepos().entrySet()) { String repo = Objects.requireNonNull(kv.getValue()); // Check the type. if (repo.startsWith("http:") || repo.startsWith("https://")) { String repoName = kv.getKey(); Optional<PasswordAuthentication> credentials = downloadConfig.getRepoCredentials(repoName); downloaders.add(new RemoteMavenDownloader(httpDownloader, repo, credentials)); } else if (repo.startsWith("file:")) { try { URL url = new URL(repo); Objects.requireNonNull(url.getPath()); downloaders.add(new OnDiskMavenDownloader( config.resolvePathThatMayBeOutsideTheProjectFilesystem(Paths.get(url.getPath())))); } catch (FileNotFoundException e) { throw new HumanReadableException(e, "Error occurred when attempting to use %s " + "as a local Maven repository as configured in .buckconfig. See " + "https://buckbuild.com/concept/buckconfig.html#maven_repositories for how to " + "configure this setting", repo);// w ww . ja v a2s. c om } catch (MalformedURLException e) { throw new HumanReadableException("Unable to determine path from %s", repo); } } else { try { downloaders.add(new OnDiskMavenDownloader(Objects.requireNonNull( config.resolvePathThatMayBeOutsideTheProjectFilesystem(Paths.get(repo))))); } catch (FileNotFoundException e) { throw new HumanReadableException(e, "Error occurred when attempting to use %s " + "as a local Maven repository as configured in .buckconfig. See " + "https://buckbuild.com/concept/buckconfig.html#maven_repositories for how to " + "configure this setting", repo); } } } if (toolchainProvider.isToolchainPresent(AndroidSdkLocation.DEFAULT_NAME)) { AndroidSdkLocation androidSdkLocation = toolchainProvider.getByName(AndroidSdkLocation.DEFAULT_NAME, AndroidSdkLocation.class); Path androidSdkRootPath = androidSdkLocation.getSdkRootPath(); Path androidMavenRepo = androidSdkRootPath.resolve("extras/android/m2repository"); try { downloaders.add(new OnDiskMavenDownloader(androidMavenRepo)); } catch (FileNotFoundException e) { LOG.warn("Android Maven repo %s doesn't exist", androidMavenRepo.toString()); } Path googleMavenRepo = androidSdkRootPath.resolve("extras/google/m2repository"); try { downloaders.add(new OnDiskMavenDownloader(googleMavenRepo)); } catch (FileNotFoundException e) { LOG.warn("Google Maven repo '%s' doesn't exist", googleMavenRepo.toString()); } } // Add a default downloader // TODO(simons): Remove the maven_repo check Optional<String> defaultMavenRepo = downloadConfig.getMavenRepo(); if (defaultMavenRepo.isPresent()) { LOG.warn("Please configure maven repos by adding them to a 'maven_repositories' " + "section in your buckconfig"); } OptionalInt maxNumberOfRetries = downloadConfig.getMaxNumberOfRetries(); if (maxNumberOfRetries.isPresent()) { downloaders.add(RetryingDownloader.from(httpDownloader, maxNumberOfRetries.getAsInt())); } else { downloaders.add(httpDownloader); } return new StackedDownloader(downloaders.build()); }
From source file:org.apache.calcite.materialize.LatticeRootNode.java
LatticeRootNode(LatticeSpace space, MutableNode mutableNode) { super(space, null, mutableNode); final ImmutableList.Builder<LatticeNode> b = ImmutableList.builder(); flattenTo(b);/*from w w w . ja v a 2s . c o m*/ this.descendants = b.build(); this.paths = createPaths(space); }
From source file:com.google.errorprone.bugpatterns.testdata.BadImportPositiveCases.java
public void newClass() { new ImmutableList.Builder<String>(); new ImmutableList.Builder<ImmutableList.Builder<String>>(); }
From source file:com.spotify.heroic.metric.FetchData.java
public static Collector<Result, Result> collectResult(final QueryTrace.Identifier what) { final QueryTrace.NamedWatch w = QueryTrace.watch(what); return results -> { final ImmutableList.Builder<QueryTrace> traces = ImmutableList.builder(); final ImmutableList.Builder<RequestError> errors = ImmutableList.builder(); for (final Result result : results) { traces.add(result.trace);/*from ww w . ja v a 2 s . com*/ errors.addAll(result.errors); } return new Result(w.end(traces.build()), errors.build()); }; }