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:zookeeper.recipes.locks.InterProcessMultiLock.java

private static List<InterProcessLock> makeLocks(CuratorFramework client, List<String> paths) {
    ImmutableList.Builder<InterProcessLock> builder = ImmutableList.builder();
    for (String path : paths) {
        InterProcessLock lock = new InterProcessMutex(client, path);
        builder.add(lock);
    }//from   w w  w. j ava2  s  .  c o m
    return builder.build();
}

From source file:org.waveprotocol.box.server.waveserver.WaveletNotificationDispatcher.java

/** Picks out the transformed deltas from a list of delta records. */
private static ImmutableList<TransformedWaveletDelta> transformedDeltasOf(
        Iterable<WaveletDeltaRecord> deltaRecords) {
    ImmutableList.Builder<TransformedWaveletDelta> transformedDeltas = ImmutableList.builder();
    for (WaveletDeltaRecord deltaRecord : deltaRecords) {
        transformedDeltas.add(deltaRecord.getTransformedDelta());
    }//from  ww  w  . j  a  va  2  s  .  co  m
    return transformedDeltas.build();
}

From source file:org.apache.tajo.type.TypeProtobufEncoder.java

public static Type decode(TypeProto proto) {
    Stack<Type> stack = new Stack<>();

    for (int curIdx = 0; curIdx < proto.getElementsCount(); curIdx++) {
        TypeElement e = proto.getElements(curIdx);

        if (e.hasChildNum()) { // if it is a type-parameterized, that is
            List<Type> childTypes = popMultiItems(stack, e.getChildNum());

            if (e.getKind() == ARRAY || e.getKind() == MAP) {
                stack.push(createTypeParameterizedType(e, childTypes));

            } else { // record
                assertCondition(e.getKind() == RECORD, "This type must be RECORD type.");
                assertCondition(childTypes.size() == e.getFieldNamesCount(),
                        "The number of Field types and names must be equal.");

                ImmutableList.Builder<Field> fields = ImmutableList.builder();
                for (int i = 0; i < childTypes.size(); i++) {
                    fields.add(new Field(QualifiedIdentifier.fromProto(e.getFieldNames(i)), childTypes.get(i)));
                }//from w  w w .j  a  v a2 s.  co m
                stack.push(Record(fields.build()));
            }

        } else {
            stack.push(createPrimitiveType(e));
        }
    }

    assertCondition(stack.size() == 1, "Stack size has two or more items.");
    return stack.pop();
}

From source file:com.spectralogic.ds3autogen.java.generators.requestmodels.MultiFileDeleteRequestGenerator.java

/**
 * Creates the Multi File Delete constructor that uses Iterables
 *//*from ww w . j av a 2 s.com*/
protected static RequestConstructor createIterableConstructor(final ImmutableList<Arguments> constructorArgs,
        final ImmutableList<QueryParam> queryParams, final String requestName, final Ds3DocSpec docSpec) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();

    if (hasContent(constructorArgs)) {
        constructorArgs.stream().filter(arg -> !arg.getName().equalsIgnoreCase("Delete")).forEach(builder::add);
    }

    builder.add(new Arguments("Iterable<Contents>", "Objs"));

    final ImmutableList<String> additionalLines = ImmutableList.of("this.objects = contentsToString(objs);");

    final ImmutableList<String> argNames = builder.build().stream().map(Arguments::getName)
            .collect(GuavaCollectors.immutableList());

    return new RequestConstructor(false, additionalLines, builder.build(), constructorArgs, queryParams,
            toConstructorDocs(requestName, argNames, docSpec, 1));
}

From source file:com.noodlewiz.xjavab.ext.res.internal.ReplyUnpacker.java

public static QueryClientResourcesReply unpackQueryClientResources(final ByteBuffer __xjb_buf) {
    __xjb_buf.position(4);//ww w  . j  a  v  a2s .c  om
    final long length = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
    __xjb_buf.position(1);
    com.noodlewiz.xjavab.core.internal.Unpacker.unpackPad(__xjb_buf, 1);
    __xjb_buf.position(8);
    final long numTypes = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
    com.noodlewiz.xjavab.core.internal.Unpacker.unpackPad(__xjb_buf, 20);
    final com.google.common.collect.ImmutableList.Builder<Type> __xjb_typesBuilder = new com.google.common.collect.ImmutableList.Builder<Type>();
    for (int __xjb_i = 0; (__xjb_i < numTypes); __xjb_i++) {
        __xjb_typesBuilder.add(com.noodlewiz.xjavab.ext.res.internal.Unpacker.unpackType(__xjb_buf));
    }
    final List<Type> types = __xjb_typesBuilder.build();
    return new QueryClientResourcesReply(numTypes, types);
}

From source file:ru.org.linux.spring.SameIPController.java

private static List<UserItem> getUsers(Connection db, String ip, int uaId) throws SQLException {
    Statement st = db.createStatement();
    ResultSet rs = st.executeQuery("SELECT MAX(c.postdate) AS lastdate, u.nick, c.ua_id, ua.name AS user_agent "
            + "FROM comments c LEFT JOIN user_agents ua ON c.ua_id = ua.id "
            + "JOIN users u ON c.userid = u.id " + "WHERE c.postip='" + ip + "' "
            + "GROUP BY u.nick, c.ua_id, ua.name " + "ORDER BY MAX(c.postdate) DESC, u.nick, ua.name");

    ImmutableList.Builder<UserItem> res = ImmutableList.builder();

    while (rs.next()) {
        res.add(new UserItem(rs, uaId));
    }//from   w  ww .  j a  va 2 s .  c o m

    rs.close();
    st.close();

    return res.build();
}

From source file:com.noodlewiz.xjavab.ext.record.internal.ReplyUnpacker.java

public static GetContextReply unpackGetContext(final ByteBuffer __xjb_buf) {
    __xjb_buf.position(4);/*from   w w w.  j  av a 2s  .  co  m*/
    final long length = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
    __xjb_buf.position(1);
    final boolean enabled = com.noodlewiz.xjavab.core.internal.Unpacker.unpackBool(__xjb_buf);
    __xjb_buf.position(8);
    final short elementHeader = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUByte(__xjb_buf);
    com.noodlewiz.xjavab.core.internal.Unpacker.unpackPad(__xjb_buf, 3);
    final long numInterceptedClients = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
    com.noodlewiz.xjavab.core.internal.Unpacker.unpackPad(__xjb_buf, 16);
    final com.google.common.collect.ImmutableList.Builder<ClientInfo> __xjb_interceptedClientsBuilder = new com.google.common.collect.ImmutableList.Builder<ClientInfo>();
    for (int __xjb_i = 0; (__xjb_i < numInterceptedClients); __xjb_i++) {
        __xjb_interceptedClientsBuilder
                .add(com.noodlewiz.xjavab.ext.record.internal.Unpacker.unpackClientInfo(__xjb_buf));
    }
    final List<ClientInfo> interceptedClients = __xjb_interceptedClientsBuilder.build();
    return new GetContextReply(enabled, elementHeader, numInterceptedClients, interceptedClients);
}

From source file:com.huangyunkun.jviff.service.StepContainer.java

private static void assembleRunner() {
    ImmutableList.Builder<BaseRunner> builder = ImmutableList.builder();
    for (Class<? extends BaseRunner> runnerClass : Constant.RUNNER_LIST) {
        try {//from   www .  ja v a 2  s  . c om
            BaseRunner runner = runnerClass.newInstance();
            builder.add(runner);
        } catch (Exception e) {
            throw new RuntimeException();
        }
    }
    baseRunners = builder.build();
}

From source file:com.tkmtwo.sarapi.ArsContext.java

public static List<ArsContext> valuesOf(String s) {
    ImmutableList.Builder<ArsContext> ilb = new ImmutableList.Builder<ArsContext>();
    for (String cs : TkmTwoJointers.COMMA_SPLITTER.split(s)) {
        ilb.add(valueOf(cs));
    }/*from www  .  j av a2 s. co  m*/
    return ilb.build();
}

From source file:ru.org.linux.spring.SameIPController.java

private static List<TopicItem> getTopics(Connection db, String ip) throws SQLException {
    Statement st = db.createStatement();
    ResultSet rs = st.executeQuery(
            "SELECT sections.name as ptitle, groups.title as gtitle, topics.title as title, topics.id as msgid, postdate, deleted "
                    + "FROM topics, groups, sections, users " + "WHERE topics.groupid=groups.id "
                    + "AND sections.id=groups.section " + "AND users.id=topics.userid " + "AND topics.postip='"
                    + ip + "' " + "AND postdate>CURRENT_TIMESTAMP-'3 days'::interval ORDER BY msgid DESC");

    ImmutableList.Builder<TopicItem> res = ImmutableList.builder();

    while (rs.next()) {
        res.add(new TopicItem(rs, false));
    }/*from  www  .j  ava 2 s .  c  o  m*/

    rs.close();
    st.close();

    return res.build();
}