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:org.apache.aurora.scheduler.sla.SlaTestUtil.java

private static List<ITaskEvent> makeEvents(Map<Long, ScheduleStatus> events) {
    ImmutableList.Builder<ITaskEvent> taskEvents = ImmutableList.builder();
    for (Map.Entry<Long, ScheduleStatus> entry : events.entrySet()) {
        taskEvents.add(ITaskEvent.build(new TaskEvent(entry.getKey(), entry.getValue())));
    }/*from   w ww  .ja  va 2 s  .c  o  m*/

    return taskEvents.build();
}

From source file:com.spectralogic.ds3autogen.java.utils.CommonRequestGeneratorUtils.java

/**
 * Creates a constructor with the provided parameters in addition to
 * adding the required parameter Channel for parsing a request payload.
 *//*from ww  w. jav  a 2  s  . c om*/
public static RequestConstructor createChannelConstructor(final ImmutableList<Arguments> parameters,
        final ImmutableList<QueryParam> queryParams, final String requestName, final Ds3DocSpec docSpec) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(parameters);
    builder.add(new Arguments("SeekableByteChannel", "Channel"));

    final ImmutableList<String> additionalLines = ImmutableList
            .of("this.stream = new SeekableByteChannelInputStream(channel);");

    final ImmutableList<Arguments> updatedParameters = builder.build();

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

    return new RequestConstructor(false, additionalLines, updatedParameters, updatedParameters, queryParams,
            toConstructorDocs(requestName, argNames, docSpec, 1));
}

From source file:net.morimekta.providence.generator.format.java.JavaMessageFormatter.java

private static List<MessageMemberFormatter> getFormatters(IndentedPrintWriter writer, JHelper helper,
        JavaOptions options) {/* ww  w  . j  a  va  2s  .c  om*/
    ImmutableList.Builder<MessageMemberFormatter> builderFormatters = ImmutableList.builder();
    builderFormatters.add(new BuilderCommonMemberFormatter(writer, helper))
            .add(new BuilderCoreOverridesFormatter(writer, helper));

    if (options.hazelcast_portable) {
        builderFormatters.add(new HazelcastPortableMessageFormatter(writer, helper));
    }

    ImmutableList.Builder<MessageMemberFormatter> formatters = ImmutableList.builder();
    formatters.add(new CommonMemberFormatter(writer, helper)).add(new CoreOverridesFormatter(writer))
            .add(new CommonOverridesFormatter(writer));

    if (options.android) {
        formatters.add(new AndroidMessageFormatter(writer));
    }
    if (options.jackson) {
        formatters.add(new JacksonMessageFormatter(writer, helper));
    }
    if (options.rw_binary) {
        formatters.add(new BinaryWriterFormatter(writer, helper));
        builderFormatters.add(new BinaryReaderBuilderFormatter(writer, helper));
    }

    formatters.add(new CommonBuilderFormatter(writer, helper, builderFormatters.build()));
    return formatters.build();
}

From source file:com.squareup.wire.schema.Extend.java

static ImmutableList<ExtendElement> toElements(ImmutableList<Extend> extendList) {
    ImmutableList.Builder<ExtendElement> elements = new ImmutableList.Builder<>();
    for (Extend extend : extendList) {
        elements.add(ExtendElement.builder(extend.location).documentation(extend.documentation)
                .name(extend.name).fields(Field.toElements(extend.fields)).build());
    }//  w w  w .j  a va2s . c  o  m
    return elements.build();
}

From source file:io.prestosql.plugin.raptor.legacy.util.ArrayUtil.java

/**
 * Unpack an array of big endian ints.//from   w  ww  . j  ava 2 s .  c o m
 */
public static List<Integer> intArrayFromBytes(byte[] bytes) {
    ImmutableList.Builder<Integer> list = ImmutableList.builder();
    ByteBuffer buffer = ByteBuffer.wrap(bytes);
    while (buffer.hasRemaining()) {
        list.add(buffer.getInt());
    }
    return list.build();
}

From source file:com.google.template.soy.exprtree.ExprRootNode.java

public static List<ExprNode> unwrap(Iterable<ExprRootNode> exprs) {
    ImmutableList.Builder<ExprNode> builder = ImmutableList.builder();
    for (ExprRootNode expr : exprs) {
        builder.add(expr.getRoot());
    }/*from   w ww  .j a  v  a2s  .  co  m*/
    return builder.build();
}

From source file:com.google.template.soy.exprtree.ExprRootNode.java

public static List<ExprRootNode> wrap(Iterable<? extends ExprNode> exprs) {
    ImmutableList.Builder<ExprRootNode> builder = ImmutableList.builder();
    for (ExprNode expr : exprs) {
        builder.add(new ExprRootNode(expr));
    }/* w w w  . j  a  v  a2  s  . c o m*/
    return builder.build();
}

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

/**
 * Prefixes each of the given linker arguments with "-Xlinker" so that the compiler linker
 * driver will pass these arguments directly down to the linker rather than interpreting them
 * itself.//from  www.ja v a2 s . c  o  m
 *
 * e.g. ["-rpath", "hello/world"] -&gt; ["-Xlinker", "-rpath", "-Xlinker", "hello/world"]
 *
 * Arguments that do not contain commas can instead be passed using the shorter
 * "-Wl,ARGUMENT" form.
 *
 * e.g., ["-rpath", "hello/world"] -&gt; ["-Wl,-rpath", "-Wl,hello/world" ]
 *
 * @param args arguments for the linker.
 * @return arguments to be passed to the compiler linker driver.
 */
public static Iterable<String> iXlinker(Iterable<String> args) {
    ImmutableList.Builder<String> escaped = ImmutableList.builder();
    for (String arg : args) {
        if (arg.contains(",")) {
            escaped.add("-Xlinker");
            escaped.add(arg);
        } else {
            escaped.add("-Wl," + arg);
        }
    }

    return escaped.build();
}

From source file:org.apache.calcite.util.CompositeMap.java

private static <E> ImmutableList<E> list(E e, E[] es) {
    ImmutableList.Builder<E> builder = ImmutableList.builder();
    builder.add(e);
    for (E map : es) {
        builder.add(map);/*from   ww  w. ja v a2 s.  com*/
    }
    return builder.build();
}

From source file:org.apache.james.transport.util.MailAddressUtils.java

private static List<MailAddress> from(List<InternetAddress> internetAddresses) throws AddressException {
    ImmutableList.Builder<MailAddress> builder = ImmutableList.builder();
    for (InternetAddress internetAddress : internetAddresses) {
        builder.add(new MailAddress(internetAddress));
    }//ww w  .j ava2s.c o  m
    return builder.build();
}