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

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

Introduction

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

Prototype

boolean add(E e);

Source Link

Document

Appends the specified element to the end of this list (optional operation).

Usage

From source file:com.facebook.presto.operator.scalar.ListLiteralCast.java

@ScalarOperator(OperatorType.CAST)
@SqlType(ListLiteralType.NAME)// ww  w.  j a  v a 2s .  c o m
public static List<List<Integer>> castArrayOfArraysToListLiteral(
        @SqlType("array(array(integer))") Block arrayOfArrays) {
    ArrayType arrayType = new ArrayType(INTEGER);
    ImmutableList.Builder<List<Integer>> outerListBuilder = ImmutableList.builder();
    for (int i = 0; i < arrayOfArrays.getPositionCount(); i++) {
        Block subArray = arrayType.getObject(arrayOfArrays, i);
        outerListBuilder.add(castArrayToListLiteral(subArray));
    }

    return outerListBuilder.build();
}

From source file:com.spectralogic.ds3autogen.net.generators.parsers.typeset.BaseTypeParserSetGenerator.java

/**
 * Converts all non-enum types within a Ds3Types list into a list of TypeParsers
 *//*from w ww .  j a  v  a 2  s.  co  m*/
protected static ImmutableList<TypeParser> toTypeParserList(final ImmutableMap<String, Ds3Type> typeMap) {
    if (isEmpty(typeMap)) {
        return ImmutableList.of();
    }

    final ImmutableList.Builder<TypeParser> builder = ImmutableList.builder();
    for (final Ds3Type ds3Type : typeMap.values().asList()) {
        if (!isEnum(ds3Type)) {
            builder.add(toTypeParser(ds3Type));
        }
    }
    return builder.build();
}

From source file:com.google.appengine.tools.cloudstorage.oauth.URLFetchUtils.java

/** Gets the values of all headers with the name {@code headerName}. */
static List<String> getHeaders(HTTPResponse resp, String headerName) {
    ImmutableList.Builder<String> b = ImmutableList.builder();
    for (HTTPHeader h : resp.getHeadersUncombined()) {
        if (headerName.equalsIgnoreCase(h.getName())) {
            b.add(h.getValue());
        }//from  w w  w.  j a  va  2s  . co m
    }
    return b.build();
}

From source file:org.thelq.pircbotx.keepalive.JenkinsKeepAlive.java

public static void create() {
    Preconditions.checkState(!created, "Already created");
    created = true;/*from   w ww.  j  av a  2s  .co m*/
    ImmutableList.Builder<String> jenkinsBotsBuilder = ImmutableList.builder();
    for (int i = 1;; i++) {

        String value = "";
        if (value == null)
            break;
        jenkinsBotsBuilder.add(value);
    }

    ImmutableList<String> jenkinsBots = jenkinsBotsBuilder.build();
    if (jenkinsBots.size() == 0)
        throw new RuntimeException("No jenkins bots setup!");
    log.info("Created jenkins keep alive for " + jenkinsBots.toString());
    KeepAlive.getExecutor().scheduleAtFixedRate(new JenkinsRunner(jenkinsBots), 0, 15, TimeUnit.MINUTES);
}

From source file:org.caleydo.view.crossword.api.ui.layout.GraphFunctions.java

/**
 * return the children of this parent {@link IGraphVertex}
 *
 * @param parent/*from w ww.j ava2s . c  o  m*/
 * @return
 */
public static final ImmutableCollection<IGraphVertex> getChildren(IGraphVertex parent) {
    ImmutableList.Builder<IGraphVertex> children = ImmutableList.builder();
    for (IGraphEdge edge : parent.getEdges()) {
        if (edge.getType() == EEdgeType.PARENT_CHILD && edge.getSource() == parent)
            children.add(edge.getTarget());
    }
    return children.build();
}

From source file:com.facebook.buck.util.env.BuckClasspath.java

/**
 * Return Buck's classpath when running under Intellij. Use getClasspath() or
 * getBootstrapClasspath() instead.//from w w w .  j av a 2  s.  c  o m
 */
public static ImmutableList<Path> getBuckClasspathForIntellij() throws IOException {
    ImmutableList.Builder<Path> classPathEntries = ImmutableList.builder();
    Path productionPath = getClassLocation(BuckClasspath.class);
    classPathEntries.add(productionPath.toAbsolutePath());
    Path testPath = productionPath.resolve("../../test/buck").normalize();
    classPathEntries.add(testPath.toAbsolutePath());
    classPathEntries.addAll(filterAntClasspaths(readClasspaths(Paths.get("programs", "classpaths"))));
    classPathEntries.addAll(filterAntClasspaths(readClasspaths(Paths.get("programs", "test_classpaths"))));
    return classPathEntries.build();
}

From source file:co.cask.cdap.metrics.query.TimeSeriesResponse.java

public static Builder builder(final long start, final long end) {
    final ImmutableList.Builder<TimeValue> timeValues = ImmutableList.builder();

    return new Builder() {
        @Override/*from  www .  j a  v a 2s .  c  o  m*/
        public Builder addData(long timestamp, long value) {
            timeValues.add(new TimeValue(timestamp, value));
            return this;
        }

        @Override
        public TimeSeriesResponse build() {
            return new TimeSeriesResponse(start, end, timeValues.build());
        }
    };
}

From source file:com.facebook.buck.cxx.elf.ElfSymbolTable.java

public static ElfSymbolTable parse(ElfHeader.EIClass eiClass, ByteBuffer buffer) {
    ImmutableList.Builder<Entry> entries = ImmutableList.builder();
    while (buffer.hasRemaining()) {
        entries.add(Entry.parse(eiClass, buffer));
    }//w w  w  .  j  a v  a2s . co m
    return new ElfSymbolTable(entries.build());
}

From source file:com.noodlewiz.xjavab.core.xcmisc.internal.ReplyUnpacker.java

public static GetXIDListReply unpackGetXIDList(final ByteBuffer __xjb_buf) {
    __xjb_buf.position(4);//  www .j  av  a  2 s. c o m
    final long length = Unpacker.unpackUInt(__xjb_buf);
    __xjb_buf.position(1);
    Unpacker.unpackPad(__xjb_buf, 1);
    __xjb_buf.position(8);
    final long idsLen = Unpacker.unpackUInt(__xjb_buf);
    Unpacker.unpackPad(__xjb_buf, 20);
    final com.google.common.collect.ImmutableList.Builder<Long> __xjb_idsBuilder = new com.google.common.collect.ImmutableList.Builder<Long>();
    for (int __xjb_i = 0; (__xjb_i < idsLen); __xjb_i++) {
        __xjb_idsBuilder.add(Unpacker.unpackUInt(__xjb_buf));
    }
    final List<Long> ids = __xjb_idsBuilder.build();
    return new GetXIDListReply(idsLen, ids);
}

From source file:com.spectralogic.ds3client.helpers.strategy.StrategyUtils.java

private static ImmutableList<BulkObject> filterObjects(final List<BulkObject> blobs) {
    final ImmutableList.Builder<BulkObject> builder = ImmutableList.builder();
    for (final BulkObject blob : blobs) {
        if (!blob.getInCache()) {
            builder.add(blob);
        }//w  w  w .ja  va2  s  .c o  m
    }
    return builder.build();
}