List of usage examples for com.google.common.collect ImmutableList builder
public static <E> Builder<E> builder()
From source file:guru.qas.martini.tag.DefaultCategory.java
public DefaultCategory(String name, @Nullable Collection<String> parentNames) { this.name = checkNotNull(name, "null String").trim(); checkState(!this.name.isEmpty(), "empty String"); ImmutableList.Builder<String> builder = ImmutableList.builder(); if (null != parentNames) { for (String parentName : parentNames) { builder.add(parentName.trim()); }//from w w w . ja va2s. c o m } this.parentNames = builder.build(); }
From source file:net.techcable.pineapple.collect.ImmutableLists.java
@Nonnull public static <T, U> ImmutableList<U> transform(ImmutableList<T> list, Function<T, U> transformer) { ImmutableList.Builder<U> resultBuilder = builder(checkNotNull(list, "Null list").size()); for (int i = 0; i < list.size(); i++) { T oldElement = list.get(i);//from w w w .j a va 2s . c om U newElement = checkNotNull(transformer, "Null transformer").apply(oldElement); if (newElement == null) throw new NullPointerException( "Transformer " + transformer.getClass().getTypeName() + " returned null."); resultBuilder.add(newElement); } return resultBuilder.build(); }
From source file:at.ac.univie.isc.asio.engine.CommandBuilder.java
private CommandBuilder() { accepted = ImmutableList.builder(); arguments = ImmutableListMultimap.builder(); }
From source file:com.facebook.buck.cpp.ArStep.java
@Override protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) { ImmutableList.Builder<String> cmdBuilder = ImmutableList.builder(); cmdBuilder.add(AR).add("-q") /* do not check for existing objects */ .add(outputFile.toString()); for (Path src : srcs) { cmdBuilder.add(src.toString());// ww w . j a v a 2s . c om } return cmdBuilder.build(); }
From source file:com.google.devtools.build.lib.rules.cpp.DiscoveredSourceInputsHelper.java
/** * Converts PathFragments into source Artifacts using an ArtifactResolver, ignoring any that are * already in mandatoryInputs. Silently drops any PathFragments that cannot be resolved into * Artifacts.//from w w w. j a v a2 s .c o m */ public static ImmutableList<Artifact> getDiscoveredInputsFromPaths(Iterable<Artifact> mandatoryInputs, ArtifactResolver artifactResolver, Collection<PathFragment> inputPaths) { Set<PathFragment> knownPathFragments = new HashSet<>(); for (Artifact input : mandatoryInputs) { knownPathFragments.add(input.getExecPath()); } ImmutableList.Builder<Artifact> foundInputs = ImmutableList.builder(); for (PathFragment execPath : inputPaths) { if (!knownPathFragments.add(execPath)) { // Don't add any inputs that we already added, or original inputs, which we probably // couldn't convert into artifacts anyway. continue; } Artifact artifact = artifactResolver.resolveSourceArtifact(execPath); // It is unlikely that this artifact is null, but tolerate the situation just in case. // It is safe to ignore such paths because dependency checker would identify change in inputs // (ignored path was used before) and will force action execution. if (artifact != null) { foundInputs.add(artifact); } } return foundInputs.build(); }
From source file:com.android.build.gradle.internal.pipeline.FilterableStreamCollection.java
@NonNull public ImmutableList<TransformStream> getStreams(@NonNull StreamFilter streamFilter) { ImmutableList.Builder<TransformStream> streamsByType = ImmutableList.builder(); for (TransformStream s : getStreams()) { if (streamFilter.accept(s.getContentTypes(), s.getScopes())) { streamsByType.add(s);/*from ww w . j a va2 s. co m*/ } } return streamsByType.build(); }
From source file:com.google.devtools.build.lib.rules.cpp.FlagList.java
@VisibleForTesting ImmutableList<String> evaluate() { ImmutableList.Builder<String> result = ImmutableList.builder(); result.addAll(prefixFlags);/*from w w w . j a v a 2s. c o m*/ result.addAll(suffixFlags); return result.build(); }
From source file:com.spotify.heroic.aggregation.Chain.java
private static List<Aggregation> flattenChain(final List<Aggregation> chain) { final ImmutableList.Builder<Aggregation> child = ImmutableList.builder(); for (final Aggregation a : chain) { if (a instanceof Chain) { child.addAll(flattenChain(Chain.class.cast(a).getChain())); } else {//from w ww . java 2s . c om child.add(a); } } return child.build(); }
From source file:org.smartdeveloperhub.harvesters.it.frontend.publisher.PublisherFactory.java
private static List<CollectorConfiguration> toConfiguration(final URI instance, final Notifications notifications) { final ImmutableList.Builder<CollectorConfiguration> builder = ImmutableList.builder(); if (notifications != null) { final CollectorConfiguration result = new CollectorConfiguration(); result.setInstance(instance.toString()); result.setBrokerHost(notifications.getBrokerHost()); result.setBrokerPort(notifications.getBrokerPort()); result.setVirtualHost(notifications.getVirtualHost()); result.setExchangeName(notifications.getExchangeName()); LOGGER.debug("Using collector configuration {}", result); builder.add(result);/*w w w . j a va2 s .c o m*/ } return builder.build(); }
From source file:org.thelq.stackexchange.dbimport.sources.FolderDumpContainer.java
public FolderDumpContainer(File folder) { if (!folder.isDirectory()) throw new IllegalArgumentException("File " + folder.getAbsolutePath() + " is not a folder"); this.folder = folder; this.name = folder.getName(); //Add all the files ImmutableList.Builder<DumpEntry> entriesBuilder = ImmutableList.builder(); for (File curFile : folder.listFiles()) { if (!curFile.getName().endsWith(".xml")) { log.info("Ignoring non-XML file " + curFile.getAbsolutePath()); continue; }// www .j a va 2 s . c o m entriesBuilder.add(new FileDumpEntry(curFile)); } this.entries = entriesBuilder.build(); }