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:io.prestosql.tests.statistics.MetricComparator.java

static List<MetricComparison> getMetricComparisons(String query, QueryRunner runner, List<Metric> metrics) {
    List<OptionalDouble> estimatedValues = getEstimatedValues(metrics, query, runner);
    List<OptionalDouble> actualValues = getActualValues(metrics, query, runner);

    ImmutableList.Builder<MetricComparison> metricComparisons = ImmutableList.builder();
    for (int i = 0; i < metrics.size(); ++i) {
        //noinspection unchecked
        metricComparisons
                .add(new MetricComparison(metrics.get(i), estimatedValues.get(i), actualValues.get(i)));
    }// ww w .  j a  v  a  2  s  .  co  m
    return metricComparisons.build();
}

From source file:com.kratos.birt.report.data.oda.kairosdb.json.BeanValidationException.java

private static List<String> messagesFor(Set<ConstraintViolation<Object>> violations, String context) {
    ImmutableList.Builder<String> messages = new ImmutableList.Builder<String>();
    for (ConstraintViolation<?> violation : violations) {
        if (context != null && !context.isEmpty())
            messages.add(context + "." + violation.getPropertyPath().toString() + " " + violation.getMessage());
        else/* w  ww  . ja  v  a  2 s  . c  o m*/
            messages.add(violation.getPropertyPath().toString() + " " + violation.getMessage());
    }

    return messages.build();
}

From source file:org.apache.gobblin.metrics.Tag.java

/**
 * Converts a {@link Map} of key, value pairs to a {@link List} of {@link Tag}s. Each key, value pair will be used to
 * create a new {@link Tag}.//  w w w .j a  v  a  2 s .co  m
 *
 * @param tagsMap a {@link Map} of key, value pairs that should be converted into {@link Tag}s
 *
 * @return a {@link List} of {@link Tag}s
 */
public static <T> List<Tag<T>> fromMap(Map<? extends String, T> tagsMap) {
    ImmutableList.Builder<Tag<T>> tagsBuilder = ImmutableList.builder();
    for (Map.Entry<? extends String, T> entry : tagsMap.entrySet()) {
        tagsBuilder.add(new Tag<>(entry));
    }
    return tagsBuilder.build();
}

From source file:de.flapdoodle.guava.Merger.java

public static <T> ImmutableList<T> remove(Iterable<? extends T> src, Predicate<? super T> matcher,
        Function<T, Optional<T>> transformation) {
    ImmutableList.Builder<T> builder = ImmutableList.builder();
    for (T s : src) {
        if (matcher.apply(s)) {
            builder.addAll(transformation.apply(s).asSet());
        } else {//from  w  w  w.j  a  v a  2 s .c  o m
            builder.add(s);
        }
    }
    return builder.build();
}

From source file:com.ibm.common.activitystreams.internal.MultimapAdapter.java

/**
 * Method arraydes./*from  w w w  .  ja  va  2s.  c o m*/
 * @param array JsonArray
 * @param context JsonDeserializationContext
        
 * @return ImmutableList<Object> */
protected static ImmutableList<Object> arraydes(JsonArray array, JsonDeserializationContext context) {
    ImmutableList.Builder<Object> builder = ImmutableList.builder();
    for (JsonElement child : array)
        if (child.isJsonArray())
            builder.add(arraydes(child.getAsJsonArray(), context));
        else if (child.isJsonObject())
            builder.add(context.deserialize(child, ASObject.class));
        else if (child.isJsonPrimitive())
            builder.add(primConverter.convert(child.getAsJsonPrimitive()));
    return builder.build();
}

From source file:io.prestosql.benchmark.driver.Suite.java

public static List<Suite> readSuites(File file) throws IOException {
    requireNonNull(file, "file is null");
    checkArgument(file.canRead(), "Cannot read file: %s", file);
    byte[] json = Files.readAllBytes(file.toPath());
    Map<String, OptionsJson> options = mapJsonCodec(String.class, OptionsJson.class).fromJson(json);
    ImmutableList.Builder<Suite> runOptions = ImmutableList.builder();
    for (Entry<String, OptionsJson> entry : options.entrySet()) {
        runOptions.add(entry.getValue().toSuite(entry.getKey()));
    }//from   w  w w  . j a  va  2  s.c  om
    return runOptions.build();
}

From source file:com.facebook.presto.benchmark.driver.Suite.java

public static List<Suite> readSuites(File file) throws IOException {
    requireNonNull(file, "file is null");
    checkArgument(file.canRead(), "Can not read file: %s" + file);
    byte[] json = Files.readAllBytes(file.toPath());
    Map<String, OptionsJson> options = mapJsonCodec(String.class, OptionsJson.class).fromJson(json);
    ImmutableList.Builder<Suite> runOptions = ImmutableList.builder();
    for (Entry<String, OptionsJson> entry : options.entrySet()) {
        runOptions.add(entry.getValue().toSuite(entry.getKey()));
    }//  www.  j a  v  a2 s . co  m
    return runOptions.build();
}

From source file:ec.nbdemetra.odbc.OdbcRegistry.java

private static ImmutableList<String> readFileExtns(Object obj) {
    if (obj == null) {
        return ImmutableList.of();
    }//from   w w  w .jav  a 2 s .c om
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    for (String o : EXTNS_SPLITTER.split(obj.toString())) {
        builder.add(Files.getFileExtension(o));
    }
    return builder.build();
}

From source file:com.spectralogic.ds3autogen.converters.RemoveSpectraInternalConverter.java

/**
 * Removes all Spectra Internal requests form a list of Ds3Requests
 *//*from   www .  j  a va 2 s.  co m*/
protected static ImmutableList<Ds3Request> removeSpectraInternalRequests(
        final ImmutableList<Ds3Request> requests) {
    if (isEmpty(requests)) {
        return ImmutableList.of();
    }
    final ImmutableList.Builder<Ds3Request> builder = ImmutableList.builder();
    for (final Ds3Request request : requests) {
        if (request.getClassification() != Classification.spectrainternal) {
            builder.add(request);
        }
    }
    return builder.build();
}

From source file:com.wrmsr.wava.util.collect.MoreLists.java

public static <T> SplitStream<T> splitStream(Stream<T> stream, Predicate<T> predicate) {
    ImmutableList.Builder<T> matches = ImmutableList.builder();
    ImmutableList.Builder<T> nonMatches = ImmutableList.builder();
    stream.forEach(e -> {// w  w  w . ja va2 s .  c om
        if (predicate.test(e)) {
            matches.add(e);
        } else {
            nonMatches.add(e);
        }
    });
    return new SplitStream<>(matches.build(), nonMatches.build());
}