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.presto.orc.writer.MapColumnWriter.java

@Override
public List<Stream> writeIndexStreams(SliceOutput outputStream, MetadataWriter metadataWriter)
        throws IOException {
    checkState(closed);/*  w ww.  j  ava2s .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(keyWriter.writeIndexStreams(outputStream, metadataWriter));
    indexStreams.addAll(valueWriter.writeIndexStreams(outputStream, metadataWriter));
    return indexStreams.build();
}

From source file:org.robotninjas.util.composition.FunctionComposition.java

private ImmutableList<Stage> addStage(ImmutableList<Stage> stages, Stage stage) {
    ImmutableList.Builder builder = ImmutableList.builder();
    return builder.addAll(stages).add(stage).build();
}

From source file:com.google.api.codegen.transformer.ruby.RubyApiMethodParamTransformer.java

@Override
public List<ParamDocView> generateParamDocs(GapicMethodContext context) {
    ImmutableList.Builder<ParamDocView> docs = ImmutableList.builder();
    if (context.getMethodModel().getRequestStreaming()) {
        docs.add(generateRequestStreamingParamDoc(context));
    } else {//  w w w .java  2  s . co  m
        docs.addAll(generateMethodParamDocs(context, context.getMethodConfig().getRequiredFields()));
        docs.addAll(generateMethodParamDocs(context, context.getMethodConfig().getOptionalFields()));
    }
    docs.add(generateOptionsParamDoc());
    return docs.build();
}

From source file:com.facebook.buck.cxx.Preprocessor.java

/**
 * @param prefixHeader the {@code prefix_hedaer} param for the rule.
 * @param pchOutputPath either a {@code precompiled_header} path, or the result of precompiling
 *        {@code prefixHeader}.  Not mutually exclusive with {@code prefixHeader}; if both are
 *        given, the precompiled version of it is preferred.
 *///from  www . j  ava 2 s.  c o  m
default Iterable<String> prefixOrPCHArgs(SourcePathResolver resolver, Optional<SourcePath> prefixHeader,
        Optional<Path> pchOutputPath) {
    ImmutableList.Builder<String> builder = ImmutableList.<String>builder();
    if (pchOutputPath.isPresent()) {
        Preconditions.checkState(this.supportsPrecompiledHeaders(),
                "Precompiled header was requested, but is not supported by " + getClass().toString());
        builder.addAll(precompiledHeaderArgs(pchOutputPath.get()));
    } else if (prefixHeader.isPresent()) {
        builder.addAll(prefixHeaderArgs(resolver, prefixHeader.get()));
    }
    return builder.build();
}

From source file:org.caleydo.view.domino.api.model.typed.MultiTypedList.java

@Override
public List<TypedID> asInhomogenous() {
    if (ids instanceof Single)
        return new SingleTypedIDList(((Single) ids).data);
    ImmutableList.Builder<TypedID> b = ImmutableList.builder();
    for (int i = 0; i < depth(); ++i) {
        IDType idType = idTypes[i];//w ww .ja  va  2  s.  c  o  m
        // select just the slice and map to typed id
        b.addAll(Collections2.transform(ids, Functions.compose(TypedID.toTypedId(idType), slice(i))));
    }
    return b.build();
}

From source file:com.afterkraft.kraftrpg.api.storage.PlayerData.java

/**
 * Return a collection of all active roles in the order Primary, Secondary, Additional. Past
 * roles are excluded.// w  w  w. j  a  v a  2  s  .com
 *
 * @return all active roles
 */
public Collection<Role> getAllRoles() {
    if (this.allRoles != null) {
        return this.allRoles;
    }

    ImmutableList.Builder<Role> b = ImmutableList.builder();
    if (this.primary != null) {
        b.add(this.primary);
    }
    if (this.profession != null) {
        b.add(this.profession);
    }
    b.addAll(this.additionalRoles);
    this.allRoles = b.build();

    return this.allRoles;
}

From source file:io.atomix.core.tree.DocumentPath.java

/**
 * Constructs a new document path.//w ww . ja  v  a 2  s. c  o  m
 * <p>
 * New paths must contain at least one name and string names may NOT contain any period characters.
 * If one field is {@code null} that field will be ignored.
 *
 * @param nodeName   the name of the last level of this path
 * @param parentPath the path representing the parent leading up to this
 *                   node, in the case of the root this should be {@code null}
 * @throws IllegalDocumentNameException if both parameters are null or name contains an illegal character ('.')
 */
public DocumentPath(String nodeName, DocumentPath parentPath) {
    checkNotNull(nodeName, "Node name cannot be null");
    if (nodeName.contains(PATH_SEPARATOR)) {
        throw new IllegalDocumentNameException("'" + PATH_SEPARATOR + "' are not allowed in names.");
    }

    ImmutableList.Builder<String> builder = ImmutableList.builder();
    if (parentPath != null) {
        builder.addAll(parentPath.pathElements());
    }
    builder.add(nodeName);

    pathElements = builder.build();
    if (pathElements.isEmpty()) {
        throw new IllegalDocumentNameException("A document path must contain at least one non-null element.");
    }
}

From source file:com.facebook.buck.cxx.CxxInferCapture.java

@Override
public ImmutableList<SourcePath> getInputsAfterBuildingLocally() throws IOException {
    ImmutableList.Builder<SourcePath> inputs = ImmutableList.builder();

    // include all inputs coming from the preprocessor tool.
    inputs.addAll(preprocessorDelegate.getInputsAfterBuildingLocally(readDepFileLines()));

    // Add the input.
    inputs.add(input);//from w ww  .  j  a  v a 2  s . co m

    return inputs.build();
}

From source file:io.brooklyn.ambari.hostgroup.AmbariHostGroupImpl.java

private List<AmbariAgent> getAmbariAgents(Collection<Entity> entities) {
    ImmutableList.Builder<AmbariAgent> builder = ImmutableList.<AmbariAgent>builder();
    for (Entity entity : entities) {
        if (entity instanceof AmbariAgent) {
            builder.add((AmbariAgent) entity);
        } else {//from  www.  ja  v a2 s  . c  o m
            builder.addAll(Entities.descendants(entity, AmbariAgent.class));
        }
    }

    return builder.build();
}