Example usage for com.google.common.collect ImmutableList.Builder addAll

List of usage examples for com.google.common.collect ImmutableList.Builder addAll

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList.Builder addAll.

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).

Usage

From source file:com.facebook.buck.jvm.java.DefaultJavaLibraryBuildable.java

@Override
public ImmutableList<Step> getPipelinedBuildSteps(BuildContext buildContext, ProjectFilesystem filesystem,
        JavacPipelineState state, OutputPathResolver outputPathResolver,
        BuildCellRelativePathFactory buildCellPathFactory) {
    // TODO(cjhopman): unusedDependenciesFinder is broken.
    ImmutableList<Step> factoryBuildSteps = jarBuildStepsFactory.getPipelinedBuildStepsForLibraryJar(
            buildContext, filesystem,//  w  ww .  j av  a2 s.  c o m
            ModernBuildableSupport.getDerivedArtifactVerifier(buildTarget, filesystem, this), state,
            outputPathResolver.resolvePath(pathToClassHashesOutputPath));
    ImmutableList.Builder<Step> stepsBuilder = ImmutableList
            .builderWithExpectedSize(factoryBuildSteps.size() + 1);
    stepsBuilder.addAll(factoryBuildSteps);
    addMakeMissingOutputsStep(filesystem, outputPathResolver, stepsBuilder);
    return stepsBuilder.build();
}

From source file:com.continuuity.loom.common.queue.internal.InMemoryElementsTracking.java

@Override
public List<QueuedElement> getBeingConsumed() {
    ImmutableList.Builder<QueuedElement> listBuilder = new ImmutableList.Builder<QueuedElement>();
    listBuilder.addAll(inProgress.values());
    return listBuilder.build();
}

From source file:org.lanternpowered.server.command.CommandWeather.java

@Override
public void completeSpec(PluginContainer pluginContainer, CommandSpec.Builder specBuilder) {
    specBuilder.arguments(/*from ww  w  . j av  a 2 s  . c  om*/
            GenericArguments.flags().valueFlag(GenericArguments.world(CommandHelper.WORLD_KEY), "-world", "w")
                    .buildWith(GenericArguments.none()),
            new PatternMatchingCommandElement(Text.of("type")) {
                @Override
                protected Iterable<String> getChoices(CommandSource source) {
                    Collection<Weather> weathers = Sponge.getRegistry().getAllOf(Weather.class);
                    ImmutableList.Builder<String> builder = ImmutableList.builder();
                    for (Weather weather : weathers) {
                        builder.add(weather.getId());
                        builder.addAll(((LanternWeather) weather).getAliases());
                    }
                    return builder.build();
                }

                @Override
                protected Object getValue(String choice) throws IllegalArgumentException {
                    final Optional<Weather> optWeather = Sponge.getRegistry().getType(Weather.class, choice);
                    if (!optWeather.isPresent()) {
                        return Sponge.getRegistry().getAllOf(Weather.class).stream().filter(weather -> {
                            for (String alias : ((LanternWeather) weather).getAliases()) {
                                if (alias.equalsIgnoreCase(choice)) {
                                    return true;
                                }
                            }
                            return false;
                        }).findAny().orElseThrow(
                                () -> new IllegalArgumentException("Invalid input " + choice + " was found"));
                    }
                    return optWeather.get();
                }
            }, GenericArguments.optional(GenericArguments.integer(Text.of("duration"))))
            .executor((src, args) -> {
                LanternWorldProperties world = CommandHelper.getWorldProperties(src, args);
                WeatherUniverse weatherUniverse = world.getWorld().get().getWeatherUniverse().orElse(null);
                Weather type = args.<Weather>getOne("type").get();
                if (weatherUniverse != null) {
                    if (args.hasAny("duration")) {
                        weatherUniverse.setWeather(type, args.<Integer>getOne("duration").get() * 20);
                    } else {
                        weatherUniverse.setWeather(type);
                    }
                }
                src.sendMessage(t("Changing to " + type.getName() + " weather"));
                return CommandResult.success();
            });
}

From source file:com.android.build.gradle.internal.variant.ApkVariantOutputData.java

@NonNull
@Override//w  w w.j  a  v a  2s  .  co m
public ImmutableList<ApkOutputFile> getOutputs() {
    ImmutableList.Builder<ApkOutputFile> outputs = ImmutableList.builder();
    outputs.add(getMainOutputFile());
    if (splitZipAlign != null) {
        outputs.addAll(splitZipAlign.getOutputSplitFiles());
    } else {
        if (packageSplitResourcesTask != null) {
            outputs.addAll(packageSplitResourcesTask.getOutputSplitFiles());
        }
    }
    return outputs.build();
}

From source file:com.google.idea.blaze.java.run.producers.BlazeJavaTestMethodConfigurationProducer.java

@Override
protected boolean doSetupConfigFromContext(@NotNull BlazeCommandRunConfiguration configuration,
        @NotNull ConfigurationContext context, @NotNull Ref<PsiElement> sourceElement) {

    SelectedMethodInfo methodInfo = getSelectedMethodInfo(context);
    if (methodInfo == null) {
        return false;
    }//from ww  w. j a  va 2 s.  co m

    // PatternConfigurationProducer also chooses the first method as its source element.
    // As long as we choose an element at the same PSI hierarchy level,
    // PatternConfigurationProducer won't override our configuration.
    sourceElement.set(methodInfo.firstMethod);

    TestIdeInfo.TestSize testSize = TestSizeAnnotationMap.getTestSize(methodInfo.firstMethod);
    TargetIdeInfo target = RunUtil.targetForTestClass(context.getProject(), methodInfo.containingClass,
            testSize);
    if (target == null) {
        return false;
    }

    configuration.setTarget(target.key.label);
    BlazeCommandRunConfigurationCommonState handlerState = configuration
            .getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
    if (handlerState == null) {
        return false;
    }
    handlerState.setCommand(BlazeCommandName.TEST);

    ImmutableList.Builder<String> flags = ImmutableList.builder();
    flags.add(methodInfo.testFilterFlag);
    flags.add(BlazeFlags.TEST_OUTPUT_STREAMED);
    flags.addAll(handlerState.getBlazeFlags());

    handlerState.setBlazeFlags(flags.build());

    BlazeConfigurationNameBuilder nameBuilder = new BlazeConfigurationNameBuilder(configuration);
    nameBuilder.setTargetString(String.format("%s.%s", methodInfo.containingClass.getName(),
            String.join(",", methodInfo.methodNames)));
    configuration.setName(nameBuilder.build());

    return true;
}

From source file:com.nearinfinity.honeycomb.hbase.MutationFactory.java

/**
 * Build put list for a row insert with specified indices
 *
 * @param tableId/* w w  w.j a  v a  2  s. c o m*/
 * @param row
 * @param indices
 * @return The list of put mutations
 */
public List<Put> insert(long tableId, final Row row, final Collection<IndexSchema> indices) {
    checkNotNull(row);
    // tableId, indices checked by called methods

    final byte[] serializedRow = row.serialize();
    final UUID uuid = row.getUUID();
    final ImmutableList.Builder<Put> puts = ImmutableList.builder();

    puts.add(emptyQualifierPut(new DataRowKey(tableId, uuid), serializedRow));
    puts.addAll(insertIndices(tableId, row, indices));

    return puts.build();
}

From source file:com.facebook.presto.orc.writer.ListColumnWriter.java

@Override
public List<Stream> writeIndexStreams(SliceOutput outputStream, MetadataWriter metadataWriter)
        throws IOException {
    checkState(closed);/*from   w w w.j  a va  2  s  .  c  o m*/

    ImmutableList.Builder<RowGroupIndex> rowGroupIndexes = ImmutableList.builder();

    List<LongStreamCheckpoint> lengthCheckpoints = lengthStream.getCheckpoints();
    Optional<List<BooleanStreamCheckpoint>> presentCheckpoints = presentStream.getCheckpoints();
    for (int i = 0; i < rowGroupColumnStatistics.size(); i++) {
        int groupId = i;
        ColumnStatistics columnStatistics = rowGroupColumnStatistics.get(groupId);
        LongStreamCheckpoint lengthCheckpoint = lengthCheckpoints.get(groupId);
        Optional<BooleanStreamCheckpoint> presentCheckpoint = presentCheckpoints
                .map(checkpoints -> checkpoints.get(groupId));
        List<Integer> positions = createArrayColumnPositionList(compressed, lengthCheckpoint,
                presentCheckpoint);
        rowGroupIndexes.add(new RowGroupIndex(positions, columnStatistics));
    }

    int length = metadataWriter.writeRowIndexes(outputStream, rowGroupIndexes.build());
    Stream stream = new Stream(column, StreamKind.ROW_INDEX, length, false);

    ImmutableList.Builder<Stream> indexStreams = ImmutableList.builder();
    indexStreams.add(stream);
    indexStreams.addAll(elementWriter.writeIndexStreams(outputStream, metadataWriter));
    return indexStreams.build();
}

From source file:com.facebook.buck.android.redex.ReDexStep.java

@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) {
    ImmutableList.Builder<String> args = ImmutableList.builder();

    // In practice, redexBinaryArgs is likely to be a single argument, which is the path to the
    // ReDex binary.
    args.addAll(redexBinaryArgs);

    // Config is optional.
    if (redexConfig.isPresent()) {
        args.add("--config", redexConfig.get().toString());
    }/*from w  ww.jav  a 2  s. co m*/

    // Signing args.
    KeystoreProperties keystoreProperties = keystorePropertiesSupplier.get();
    args.add("--sign");
    args.add("--keystore", keystoreProperties.getKeystore().toString(), "--keyalias",
            keystoreProperties.getAlias(), "--keypass", keystoreProperties.getKeypass());

    // Proguard args.
    args.add("--proguard-map", proguardMap.toString());
    args.add("-P", proguardCommandLine.toString());

    args.add("--keep", seeds.toString());

    args.add("--out", outputApkPath.toString());

    args.addAll(Arg.stringify(redexExtraArgs, pathResolver));

    args.add(inputApkPath.toString());
    return args.build();
}

From source file:com.google.devtools.build.lib.query2.AbstractBlazeQueryEnvironment.java

@Override
public Iterable<QueryFunction> getFunctions() {
    ImmutableList.Builder<QueryFunction> builder = ImmutableList.builder();
    builder.addAll(DEFAULT_QUERY_FUNCTIONS);
    builder.addAll(extraFunctions);/* w ww .j  a  v  a  2s .c om*/
    return builder.build();
}

From source file:com.google.api.codegen.transformer.nodejs.NodeJSApiMethodParamTransformer.java

@Override
public List<ParamDocView> generateParamDocs(GapicMethodContext context) {
    ImmutableList.Builder<ParamDocView> docs = ImmutableList.builder();
    if (!context.getMethodModel().getRequestStreaming()) {
        docs.add(generateRequestObjectParamDoc(context));
        docs.addAll(generateMethodParamDocs(context, context.getMethodConfig().getRequiredFields(), false));
        docs.addAll(generateMethodParamDocs(context, context.getMethodConfig().getOptionalFields(), true));
    }/*from   w  ww.  j a  v a2  s  .c o  m*/
    docs.add(generateOptionsParamDoc());
    return docs.build();
}