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.rules.coercer.AbstractSourceList.java

public ImmutableList<SourcePath> getPaths() {
    ImmutableList.Builder<SourcePath> sources = ImmutableList.builder();
    switch (getType()) {
    case NAMED:/*www. ja va  2 s .c  o  m*/
        sources.addAll(getNamedSources().get().values());
        break;
    case UNNAMED:
        sources.addAll(getUnnamedSources().get());
        break;
    }
    return sources.build();
}

From source file:com.vmware.photon.controller.api.frontend.backends.FlavorLoader.java

public FlavorLoader(Map<String, Map<String, FlavorCreateSpec>> flavors) {
    this.flavors = flavors;

    ImmutableList.Builder<FlavorCreateSpec> builder = ImmutableList.builder();
    for (Map<String, FlavorCreateSpec> flavorMap : flavors.values()) {
        builder.addAll(flavorMap.values());
    }/*www  .  j  av  a2s.  c o  m*/

    this.flavorList = builder.build();
}

From source file:com.spectralogic.ds3autogen.python.generators.request.BaseRequestGenerator.java

/**
 * Gets the sorted list of required constructor parameters for a Ds3Request
 *///from w  w w . j a v a2s.  co  m
@Override
public ImmutableList<ConstructorParam> toRequiredConstructorParams(final Ds3Request ds3Request) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(getNonVoidArgsFromParamList(ds3Request.getRequiredQueryParams()));
    builder.addAll(getAssignmentArguments(ds3Request));

    return builder.build().stream().sorted(new CustomArgumentComparator())
            .map(arg -> new ConstructorParam(camelToUnderscore(arg.getName()), false))
            .collect(GuavaCollectors.immutableList());
}

From source file:org.openqa.selenium.interactions.CompositeAction.java

public List<Action> asList() {
    ImmutableList.Builder<Action> builder = new ImmutableList.Builder<Action>();
    for (Action action : actionsList) {
        if (action instanceof MultiAction) {
            builder.addAll(((MultiAction) action).getActions());
        } else {//from   w  w  w  .jav a  2  s .c  o m
            builder.add(action);
        }
    }
    return builder.build();
}

From source file:com.google.publicalerts.cap.Reasons.java

/**
 * @return the {@link Reason} objects stored in the collection, with the level specified or
 * higher// ww w.j a v  a2  s  .  c om
 */
public List<Reason> getWithLevelOrHigher(Level level) {
    checkNotNull(level);

    ImmutableList.Builder<Reason> list = ImmutableList.builder();

    list.addAll(getWithLevel(level));

    for (Level higherLevel : level.getHigherLevels()) {
        list.addAll(getWithLevel(higherLevel));
    }

    return list.build();
}

From source file:keywhiz.service.daos.SecretContentDAO.java

public Optional<ImmutableList<SecretContent>> getSecretVersionsBySecretId(long id, int versionIdx,
        int numVersions) {
    Result<SecretsContentRecord> r = dslContext.selectFrom(SECRETS_CONTENT)
            .where(SECRETS_CONTENT.SECRETID.eq(id)).orderBy(SECRETS_CONTENT.CREATEDAT.desc())
            .limit(versionIdx, numVersions).fetch();

    if (r != null && r.isNotEmpty()) {
        ImmutableList.Builder<SecretContent> b = new ImmutableList.Builder<>();
        b.addAll(r.map(secretContentMapper));
        return Optional.of(b.build());
    } else {/*from w  w w .  j ava2 s  .  c  o m*/
        return Optional.empty();
    }
}

From source file:com.dteoh.tidal.views.models.DropletModel.java

/**
 * Creates a new droplet view model by merging two droplet view models
 * together. Duplicated contents will be removed.
 * //w  ww.j  av a  2 s.com
 * @param first
 *            Base model to use when merging.
 * @param second
 *            Merge this model into the first model.
 */
private DropletModel(final DropletModel first, final DropletModel second) {
    dropletID = first.getIdentifier();
    dropletName = first.getDropletName();

    ArrayList<RippleModel> models = Lists.newArrayList(first.getDropletContents());
    models.addAll(second.dropletContents);
    Collections.sort(models);

    ArrayList<RippleModel> uniques = Lists.newArrayList();

    RippleModel prev = null;
    for (RippleModel model : models) {
        if (prev != null && model.equals(prev)) {
            continue;
        }
        uniques.add(model);
        prev = model;
    }

    final ImmutableList.Builder<RippleModel> modelBuilder = ImmutableList.builder();
    modelBuilder.addAll(uniques);

    dropletContents = modelBuilder.build();
}

From source file:com.facebook.buck.core.toolchain.tool.impl.CommandTool.java

@Override
public ImmutableList<String> getCommandPrefix(SourcePathResolver resolver) {
    ImmutableList.Builder<String> command = ImmutableList.builder();
    if (baseTool.isPresent()) {
        command.addAll(baseTool.get().getCommandPrefix(resolver));
    }/* w ww .j av a2 s  .  c  om*/
    for (Arg arg : args) {
        arg.appendToCommandLine(command::add, resolver);
    }
    return command.build();
}

From source file:com.google.devtools.build.lib.analysis.config.transitions.ComposingSplitTransition.java

@Override
public List<BuildOptions> split(BuildOptions buildOptions) {
    ImmutableList.Builder<BuildOptions> toOptions = ImmutableList.builder();
    for (BuildOptions transition1Options : transition1.apply(buildOptions)) {
        toOptions.addAll(transition2.apply(transition1Options));
    }//from   w w w.  j a  v a  2s .c o  m
    return toOptions.build();
}

From source file:com.spectralogic.ds3autogen.python.generators.request.BaseRequestGenerator.java

/**
 * Gets all constructor parameters for a Ds3Request
 */// w w w  .j a  v a2s  . co  m
@Override
public ImmutableList<String> toConstructorParams(final Ds3Request ds3Request) {
    final ImmutableList.Builder<ConstructorParam> builder = ImmutableList.builder();
    builder.addAll(toRequiredConstructorParams(ds3Request));
    builder.addAll(toOptionalConstructorParams(ds3Request));

    return builder.build().stream().map(ConstructorParam::toPythonCode)
            .collect(GuavaCollectors.immutableList());
}